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::fma:
97 case Intrinsic::fmuladd:
98 return true;
99 default:
100 return false;
101 }
102 }
103
104 /// Return true if the operand is commutable.
105 bool isCommutableOperand(unsigned Op) const {
106 constexpr unsigned NumCommutativeOps = 2;
107 return isCommutative() && Op < NumCommutativeOps;
108 }
109
110 /// Checks if the intrinsic is an annotation.
112 switch (getIntrinsicID()) {
113 default: break;
114 case Intrinsic::assume:
115 case Intrinsic::sideeffect:
116 case Intrinsic::pseudoprobe:
117 case Intrinsic::dbg_assign:
118 case Intrinsic::dbg_declare:
119 case Intrinsic::dbg_value:
120 case Intrinsic::dbg_label:
121 case Intrinsic::invariant_start:
122 case Intrinsic::invariant_end:
123 case Intrinsic::lifetime_start:
124 case Intrinsic::lifetime_end:
125 case Intrinsic::experimental_noalias_scope_decl:
126 case Intrinsic::objectsize:
127 case Intrinsic::ptr_annotation:
128 case Intrinsic::var_annotation:
129 return true;
130 }
131 return false;
132 }
133
134 /// Check if the intrinsic might lower into a regular function call in the
135 /// course of IR transformations
137
138 /// Methods for support type inquiry through isa, cast, and dyn_cast:
139 static bool classof(const CallInst *I) {
140 auto *F = dyn_cast_or_null<Function>(I->getCalledOperand());
141 return F && F->isIntrinsic();
142 }
143 static bool classof(const Value *V) {
144 return isa<CallInst>(V) && classof(cast<CallInst>(V));
145 }
146};
147
148/// Check if \p ID corresponds to a lifetime intrinsic.
149static inline bool isLifetimeIntrinsic(Intrinsic::ID ID) {
150 switch (ID) {
151 case Intrinsic::lifetime_start:
152 case Intrinsic::lifetime_end:
153 return true;
154 default:
155 return false;
156 }
157}
158
159/// This is the common base class for lifetime intrinsics.
161public:
162 /// \name Casting methods
163 /// @{
164 static bool classof(const IntrinsicInst *I) {
165 return isLifetimeIntrinsic(I->getIntrinsicID());
166 }
167 static bool classof(const Value *V) {
169 }
170 /// @}
171};
172
173/// Check if \p ID corresponds to a debug info intrinsic.
174static inline bool isDbgInfoIntrinsic(Intrinsic::ID ID) {
175 switch (ID) {
176 case Intrinsic::dbg_declare:
177 case Intrinsic::dbg_value:
178 case Intrinsic::dbg_label:
179 case Intrinsic::dbg_assign:
180 return true;
181 default:
182 return false;
183 }
184}
185
186/// This is the common base class for debug info intrinsics.
188public:
189 /// \name Casting methods
190 /// @{
191 static bool classof(const IntrinsicInst *I) {
192 return isDbgInfoIntrinsic(I->getIntrinsicID());
193 }
194 static bool classof(const Value *V) {
196 }
197 /// @}
198};
199
200// Iterator for ValueAsMetadata that internally uses direct pointer iteration
201// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
202// ValueAsMetadata .
204 : public iterator_facade_base<location_op_iterator,
205 std::bidirectional_iterator_tag, Value *> {
207
208public:
209 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
210 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
211
214 I = R.I;
215 return *this;
216 }
217 bool operator==(const location_op_iterator &RHS) const { return I == RHS.I; }
218 const Value *operator*() const {
222 return VAM->getValue();
223 };
232 I = cast<ValueAsMetadata *>(I) + 1;
233 else
234 I = cast<ValueAsMetadata **>(I) + 1;
235 return *this;
236 }
239 I = cast<ValueAsMetadata *>(I) - 1;
240 else
241 I = cast<ValueAsMetadata **>(I) - 1;
242 return *this;
243 }
244};
245
246/// Lightweight class that wraps the location operand metadata of a debug
247/// intrinsic. The raw location may be a ValueAsMetadata, an empty MDTuple,
248/// or a DIArgList.
250 Metadata *RawLocation = nullptr;
251
252public:
254 explicit RawLocationWrapper(Metadata *RawLocation)
255 : RawLocation(RawLocation) {
256 // Allow ValueAsMetadata, empty MDTuple, DIArgList.
257 assert(RawLocation && "unexpected null RawLocation");
258 assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
259 (isa<MDNode>(RawLocation) &&
260 !cast<MDNode>(RawLocation)->getNumOperands()));
261 }
262 Metadata *getRawLocation() const { return RawLocation; }
263 /// Get the locations corresponding to the variable referenced by the debug
264 /// info intrinsic. Depending on the intrinsic, this could be the
265 /// variable's value or its address.
267 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
268 unsigned getNumVariableLocationOps() const {
269 if (hasArgList())
270 return cast<DIArgList>(getRawLocation())->getArgs().size();
271 return 1;
272 }
273 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
275 // Check for "kill" sentinel values.
276 // Non-variadic: empty metadata.
278 return true;
279 // Variadic: empty DIArgList with empty expression.
280 if (getNumVariableLocationOps() == 0 && !Expression->isComplex())
281 return true;
282 // Variadic and non-variadic: Interpret expressions using undef or poison
283 // values as kills.
284 return any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
285 }
286
287 friend bool operator==(const RawLocationWrapper &A,
288 const RawLocationWrapper &B) {
289 return A.RawLocation == B.RawLocation;
290 }
291 friend bool operator!=(const RawLocationWrapper &A,
292 const RawLocationWrapper &B) {
293 return !(A == B);
294 }
295 friend bool operator>(const RawLocationWrapper &A,
296 const RawLocationWrapper &B) {
297 return A.RawLocation > B.RawLocation;
298 }
299 friend bool operator>=(const RawLocationWrapper &A,
300 const RawLocationWrapper &B) {
301 return A.RawLocation >= B.RawLocation;
302 }
303 friend bool operator<(const RawLocationWrapper &A,
304 const RawLocationWrapper &B) {
305 return A.RawLocation < B.RawLocation;
306 }
307 friend bool operator<=(const RawLocationWrapper &A,
308 const RawLocationWrapper &B) {
309 return A.RawLocation <= B.RawLocation;
310 }
311};
312
313/// This is the common base class for debug info intrinsics for variables.
315public:
316 /// Get the locations corresponding to the variable referenced by the debug
317 /// info intrinsic. Depending on the intrinsic, this could be the
318 /// variable's value or its address.
320
321 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
322
323 LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
324 bool AllowEmpty = false);
325 LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
326 /// Adding a new location operand will always result in this intrinsic using
327 /// an ArgList, and must always be accompanied by a new expression that uses
328 /// the new operand.
331
333 setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
334 }
335
339
343
344 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
345
346 /// Does this describe the address of a local variable. True for dbg.declare,
347 /// but not dbg.value, which describes its value, or dbg.assign, which
348 /// describes a combination of the variable's value and address.
349 bool isAddressOfVariable() const {
350 return getIntrinsicID() == Intrinsic::dbg_declare;
351 }
352
353 /// Determine if this describes the value of a local variable. It is true for
354 /// dbg.value, but false for dbg.declare, which describes its address, and
355 /// false for dbg.assign, which describes a combination of the variable's
356 /// value and address.
357 bool isValueOfVariable() const {
358 return getIntrinsicID() == Intrinsic::dbg_value;
359 }
360
362 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
363 // this set anymore.
364 SmallPtrSet<Value *, 4> RemovedValues;
365 for (Value *OldValue : location_ops()) {
366 if (!RemovedValues.insert(OldValue).second)
367 continue;
368 Value *Poison = PoisonValue::get(OldValue->getType());
370 }
371 }
372
373 bool isKillLocation() const {
375 }
376
380
384
386 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
387 }
388
392
394 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
395 }
396
398 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
399 }
400
401 /// Use of this should generally be avoided; instead,
402 /// replaceVariableLocationOp and addVariableLocationOps should be used where
403 /// possible to avoid creating invalid state.
404 void setRawLocation(Metadata *Location) {
405 return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
406 }
407
408 /// Get the size (in bits) of the variable, or fragment of the variable that
409 /// is described.
410 LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
411
412 /// Get the FragmentInfo for the variable.
413 std::optional<DIExpression::FragmentInfo> getFragment() const {
414 return getExpression()->getFragmentInfo();
415 }
416
417 /// Get the FragmentInfo for the variable if it exists, otherwise return a
418 /// FragmentInfo that covers the entire variable if the variable size is
419 /// known, otherwise return a zero-sized fragment.
421 DIExpression::FragmentInfo VariableSlice(0, 0);
422 // Get the fragment or variable size, or zero.
423 if (auto Sz = getFragmentSizeInBits())
424 VariableSlice.SizeInBits = *Sz;
425 if (auto Frag = getExpression()->getFragmentInfo())
426 VariableSlice.OffsetInBits = Frag->OffsetInBits;
427 return VariableSlice;
428 }
429
430 /// \name Casting methods
431 /// @{
432 static bool classof(const IntrinsicInst *I) {
433 switch (I->getIntrinsicID()) {
434 case Intrinsic::dbg_declare:
435 case Intrinsic::dbg_value:
436 case Intrinsic::dbg_assign:
437 return true;
438 default:
439 return false;
440 }
441 }
442 static bool classof(const Value *V) {
444 }
445 /// @}
446protected:
447 void setArgOperand(unsigned i, Value *v) {
449 }
450 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
451};
452
453/// This represents the llvm.dbg.declare instruction.
455public:
456 Value *getAddress() const {
458 "dbg.declare must have exactly 1 location operand.");
459 return getVariableLocationOp(0);
460 }
461
462 /// \name Casting methods
463 /// @{
464 static bool classof(const IntrinsicInst *I) {
465 return I->getIntrinsicID() == Intrinsic::dbg_declare;
466 }
467 static bool classof(const Value *V) {
469 }
470 /// @}
471};
472
473/// This represents the llvm.dbg.value instruction.
475public:
476 // The default argument should only be used in ISel, and the default option
477 // should be removed once ISel support for multiple location ops is complete.
478 Value *getValue(unsigned OpIdx = 0) const {
479 return getVariableLocationOp(OpIdx);
480 }
484
485 /// \name Casting methods
486 /// @{
487 static bool classof(const IntrinsicInst *I) {
488 return I->getIntrinsicID() == Intrinsic::dbg_value ||
489 I->getIntrinsicID() == Intrinsic::dbg_assign;
490 }
491 static bool classof(const Value *V) {
493 }
494 /// @}
495};
496
497/// This represents the llvm.dbg.assign instruction.
499 enum Operands {
500 OpValue,
501 OpVar,
502 OpExpr,
503 OpAssignID,
504 OpAddress,
505 OpAddressExpr,
506 };
507
508public:
509 LLVM_ABI Value *getAddress() const;
511 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
512 }
514 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
515 }
518 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
519 }
524 setArgOperand(OpAddressExpr,
525 MetadataAsValue::get(NewExpr->getContext(), NewExpr));
526 }
528 LLVM_ABI void setAddress(Value *V);
529 /// Kill the address component.
531 /// Check whether this kills the address component. This doesn't take into
532 /// account the position of the intrinsic, therefore a returned value of false
533 /// does not guarentee the address is a valid location for the variable at the
534 /// intrinsic's position in IR.
535 LLVM_ABI bool isKillAddress() const;
536 LLVM_ABI void setValue(Value *V);
537 /// \name Casting methods
538 /// @{
539 static bool classof(const IntrinsicInst *I) {
540 return I->getIntrinsicID() == Intrinsic::dbg_assign;
541 }
542 static bool classof(const Value *V) {
544 }
545 /// @}
546};
547
548/// This represents the llvm.dbg.label instruction.
550public:
552 void setLabel(DILabel *NewLabel) {
554 }
555
557 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
558 }
559
560 /// Methods for support type inquiry through isa, cast, and dyn_cast:
561 /// @{
562 static bool classof(const IntrinsicInst *I) {
563 return I->getIntrinsicID() == Intrinsic::dbg_label;
564 }
565 static bool classof(const Value *V) {
567 }
568 /// @}
569};
570
571/// This is the common base class for vector predication intrinsics.
573public:
574 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
575 /// \p Params. Additionally, the load and gather intrinsics require
576 /// \p ReturnType to be specified.
577 LLVM_ABI static Function *
579 ArrayRef<Value *> Params);
580
581 LLVM_ABI static std::optional<unsigned>
582 getMaskParamPos(Intrinsic::ID IntrinsicID);
583 LLVM_ABI static std::optional<unsigned>
585
586 // Whether \p ID is a VP intrinsic ID.
588
589 /// \return The mask parameter or nullptr.
590 LLVM_ABI Value *getMaskParam() const;
592
593 /// \return The vector length parameter or nullptr.
596
597 /// \return Whether the vector length param can be ignored.
599
600 /// \return The static element count (vector number of elements) the vector
601 /// length parameter applies to.
603
604 /// \return The alignment of the pointer used by this load/store/gather or
605 /// scatter.
607 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
608
609 /// \return The pointer operand of this load,store, gather or scatter.
611 LLVM_ABI static std::optional<unsigned>
613
614 /// \return The data (payload) operand of this store or scatter.
616 LLVM_ABI static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
617
618 // Methods for support type inquiry through isa, cast, and dyn_cast:
619 static bool classof(const IntrinsicInst *I) {
620 return isVPIntrinsic(I->getIntrinsicID());
621 }
622 static bool classof(const Value *V) {
624 }
625
626 // Equivalent non-predicated opcode
627 std::optional<unsigned> getFunctionalOpcode() const {
629 }
630
631 // Equivalent non-predicated intrinsic ID
632 std::optional<unsigned> getFunctionalIntrinsicID() const {
634 }
635
636 // Equivalent non-predicated opcode
637 LLVM_ABI static std::optional<unsigned>
639
640 // Equivalent non-predicated intrinsic ID
641 LLVM_ABI static std::optional<Intrinsic::ID>
643};
644
645/// This represents vector predication reduction intrinsics.
647public:
648 LLVM_ABI static bool isVPReduction(Intrinsic::ID ID);
649
650 LLVM_ABI unsigned getStartParamPos() const;
651 LLVM_ABI unsigned getVectorParamPos() const;
652
653 LLVM_ABI static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
654 LLVM_ABI static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
655
656 /// Methods for support type inquiry through isa, cast, and dyn_cast:
657 /// @{
658 static bool classof(const IntrinsicInst *I) {
659 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
660 }
661 static bool classof(const Value *V) {
663 }
664 /// @}
665};
666
667/// This is the common base class for constrained floating point intrinsics.
669public:
670 LLVM_ABI unsigned getNonMetadataArgCount() const;
671 LLVM_ABI std::optional<RoundingMode> getRoundingMode() const;
672 LLVM_ABI std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
673 LLVM_ABI bool isDefaultFPEnvironment() const;
674
675 // Methods for support type inquiry through isa, cast, and dyn_cast:
676 LLVM_ABI static bool classof(const IntrinsicInst *I);
677 static bool classof(const Value *V) {
679 }
680};
681
682/// Constrained floating point compare intrinsics.
684public:
686 bool isSignaling() const {
687 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
688 }
689
690 // Methods for support type inquiry through isa, cast, and dyn_cast:
691 static bool classof(const IntrinsicInst *I) {
692 switch (I->getIntrinsicID()) {
693 case Intrinsic::experimental_constrained_fcmp:
694 case Intrinsic::experimental_constrained_fcmps:
695 return true;
696 default:
697 return false;
698 }
699 }
700 static bool classof(const Value *V) {
702 }
703};
704
705/// This class represents min/max intrinsics.
707public:
708 static bool classof(const IntrinsicInst *I) {
709 switch (I->getIntrinsicID()) {
710 case Intrinsic::umin:
711 case Intrinsic::umax:
712 case Intrinsic::smin:
713 case Intrinsic::smax:
714 return true;
715 default:
716 return false;
717 }
718 }
719 static bool classof(const Value *V) {
721 }
722
723 Value *getLHS() const { return getArgOperand(0); }
724 Value *getRHS() const { return getArgOperand(1); }
725
726 /// Returns the comparison predicate underlying the intrinsic.
728 switch (ID) {
729 case Intrinsic::umin:
731 case Intrinsic::umax:
733 case Intrinsic::smin:
735 case Intrinsic::smax:
737 default:
738 llvm_unreachable("Invalid intrinsic");
739 }
740 }
741
742 /// Returns the comparison predicate underlying the intrinsic.
746
747 /// Whether the intrinsic is signed or unsigned.
748 static bool isSigned(Intrinsic::ID ID) {
750 };
751
752 /// Whether the intrinsic is signed or unsigned.
753 bool isSigned() const { return isSigned(getIntrinsicID()); };
754
755 /// Whether the intrinsic is a smin or umin.
756 static bool isMin(Intrinsic::ID ID) {
757 switch (ID) {
758 case Intrinsic::umin:
759 case Intrinsic::smin:
760 return true;
761 case Intrinsic::umax:
762 case Intrinsic::smax:
763 return false;
764 default:
765 llvm_unreachable("Invalid intrinsic");
766 }
767 }
768
769 /// Whether the intrinsic is a smin or a umin.
770 bool isMin() const { return isMin(getIntrinsicID()); }
771
772 /// Whether the intrinsic is a smax or a umax.
773 bool isMax() const { return !isMin(getIntrinsicID()); }
774
775 /// Returns the identity value for this min/max intrinsic, such
776 /// that minmax(X, Identity) == X.
777 static APInt getIdentity(Intrinsic::ID ID, unsigned NumBits) {
778 switch (ID) {
779 case Intrinsic::umin:
780 return APInt::getMaxValue(NumBits);
781 case Intrinsic::umax:
782 return APInt::getMinValue(NumBits);
783 case Intrinsic::smin:
784 return APInt::getSignedMaxValue(NumBits);
785 case Intrinsic::smax:
786 return APInt::getSignedMinValue(NumBits);
787 default:
788 llvm_unreachable("Invalid intrinsic");
789 }
790 }
791
792 /// Returns the identity value for this min/max intrinsic, such
793 /// that minmax(X, Identity) == X.
797
798 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
799 /// so there is a certain threshold value, upon reaching which,
800 /// their value can no longer change. Return said threshold.
801 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
802 switch (ID) {
803 case Intrinsic::umin:
804 return APInt::getMinValue(numBits);
805 case Intrinsic::umax:
806 return APInt::getMaxValue(numBits);
807 case Intrinsic::smin:
808 return APInt::getSignedMinValue(numBits);
809 case Intrinsic::smax:
810 return APInt::getSignedMaxValue(numBits);
811 default:
812 llvm_unreachable("Invalid intrinsic");
813 }
814 }
815
816 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
817 /// so there is a certain threshold value, upon reaching which,
818 /// their value can no longer change. Return said threshold.
819 APInt getSaturationPoint(unsigned numBits) const {
820 return getSaturationPoint(getIntrinsicID(), numBits);
821 }
822
823 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
824 /// so there is a certain threshold value, upon reaching which,
825 /// their value can no longer change. Return said threshold.
828 Ty, getSaturationPoint(ID, Ty->getScalarSizeInBits()));
829 }
830
831 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
832 /// so there is a certain threshold value, upon reaching which,
833 /// their value can no longer change. Return said threshold.
836 }
837};
838
839/// This class represents a ucmp/scmp intrinsic
841public:
842 static bool classof(const IntrinsicInst *I) {
843 switch (I->getIntrinsicID()) {
844 case Intrinsic::scmp:
845 case Intrinsic::ucmp:
846 return true;
847 default:
848 return false;
849 }
850 }
851 static bool classof(const Value *V) {
853 }
854
855 Value *getLHS() const { return getArgOperand(0); }
856 Value *getRHS() const { return getArgOperand(1); }
857
858 static bool isSigned(Intrinsic::ID ID) { return ID == Intrinsic::scmp; }
859 bool isSigned() const { return isSigned(getIntrinsicID()); }
860
867
874};
875
876/// This class represents an intrinsic that is based on a binary operation.
877/// This includes op.with.overflow and saturating add/sub intrinsics.
879public:
880 static bool classof(const IntrinsicInst *I) {
881 switch (I->getIntrinsicID()) {
882 case Intrinsic::uadd_with_overflow:
883 case Intrinsic::sadd_with_overflow:
884 case Intrinsic::usub_with_overflow:
885 case Intrinsic::ssub_with_overflow:
886 case Intrinsic::umul_with_overflow:
887 case Intrinsic::smul_with_overflow:
888 case Intrinsic::uadd_sat:
889 case Intrinsic::sadd_sat:
890 case Intrinsic::usub_sat:
891 case Intrinsic::ssub_sat:
892 return true;
893 default:
894 return false;
895 }
896 }
897 static bool classof(const Value *V) {
899 }
900
901 Value *getLHS() const { return getArgOperand(0); }
902 Value *getRHS() const { return getArgOperand(1); }
903
904 /// Returns the binary operation underlying the intrinsic.
906
907 /// Whether the intrinsic is signed or unsigned.
908 LLVM_ABI bool isSigned() const;
909
910 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
911 LLVM_ABI unsigned getNoWrapKind() const;
912};
913
914/// Represents an op.with.overflow intrinsic.
916public:
917 static bool classof(const IntrinsicInst *I) {
918 switch (I->getIntrinsicID()) {
919 case Intrinsic::uadd_with_overflow:
920 case Intrinsic::sadd_with_overflow:
921 case Intrinsic::usub_with_overflow:
922 case Intrinsic::ssub_with_overflow:
923 case Intrinsic::umul_with_overflow:
924 case Intrinsic::smul_with_overflow:
925 return true;
926 default:
927 return false;
928 }
929 }
930 static bool classof(const Value *V) {
932 }
933};
934
935/// Represents a saturating add/sub intrinsic.
937public:
938 static bool classof(const IntrinsicInst *I) {
939 switch (I->getIntrinsicID()) {
940 case Intrinsic::uadd_sat:
941 case Intrinsic::sadd_sat:
942 case Intrinsic::usub_sat:
943 case Intrinsic::ssub_sat:
944 return true;
945 default:
946 return false;
947 }
948 }
949 static bool classof(const Value *V) {
951 }
952};
953
954/// Common base class for all memory intrinsics. Simply provides
955/// common methods.
956/// Written as CRTP to avoid a common base class amongst the
957/// three atomicity hierarchies.
958template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
959private:
960 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
961
962public:
963 Value *getRawDest() const {
964 return const_cast<Value *>(getArgOperand(ARG_DEST));
965 }
966 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
967 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
968
969 Value *getLength() const {
970 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
971 }
972 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
973 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
974
975 std::optional<APInt> getLengthInBytes() const {
977 if (!C)
978 return std::nullopt;
979 return C->getValue();
980 }
981
982 /// This is just like getRawDest, but it strips off any cast
983 /// instructions (including addrspacecast) that feed it, giving the
984 /// original input. The returned value is guaranteed to be a pointer.
985 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
986
987 unsigned getDestAddressSpace() const {
988 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
989 }
990
991 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
992
993 /// Set the specified arguments of the instruction.
994 void setDest(Value *Ptr) {
995 assert(getRawDest()->getType() == Ptr->getType() &&
996 "setDest called with pointer of wrong type!");
997 setArgOperand(ARG_DEST, Ptr);
998 }
999
1001 removeParamAttr(ARG_DEST, Attribute::Alignment);
1002 if (Alignment)
1003 addParamAttr(ARG_DEST,
1005 }
1006 void setDestAlignment(Align Alignment) {
1007 removeParamAttr(ARG_DEST, Attribute::Alignment);
1008 addParamAttr(ARG_DEST,
1010 }
1011
1012 void setLength(Value *L) {
1013 assert(getLength()->getType() == L->getType() &&
1014 "setLength called with value of wrong type!");
1015 setArgOperand(ARG_LENGTH, L);
1016 }
1017
1019 setLength(ConstantInt::get(getLength()->getType(), L));
1020 }
1021};
1022
1023/// Common base class for all memory transfer intrinsics. Simply provides
1024/// common methods.
1025template <class BaseCL> class MemTransferBase : public BaseCL {
1026private:
1027 enum { ARG_SOURCE = 1 };
1028
1029public:
1030 /// Return the arguments to the instruction.
1032 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
1033 }
1034 const Use &getRawSourceUse() const {
1035 return BaseCL::getArgOperandUse(ARG_SOURCE);
1036 }
1037 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
1038
1039 /// This is just like getRawSource, but it strips off any cast
1040 /// instructions that feed it, giving the original input. The returned
1041 /// value is guaranteed to be a pointer.
1043
1044 unsigned getSourceAddressSpace() const {
1045 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
1046 }
1047
1049 return BaseCL::getParamAlign(ARG_SOURCE);
1050 }
1051
1052 void setSource(Value *Ptr) {
1053 assert(getRawSource()->getType() == Ptr->getType() &&
1054 "setSource called with pointer of wrong type!");
1055 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1056 }
1057
1059 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1060 if (Alignment)
1061 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1062 BaseCL::getContext(), *Alignment));
1063 }
1064
1065 void setSourceAlignment(Align Alignment) {
1066 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1067 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1068 BaseCL::getContext(), Alignment));
1069 }
1070};
1071
1072/// Common base class for all memset intrinsics. Simply provides
1073/// common methods.
1074template <class BaseCL> class MemSetBase : public BaseCL {
1075private:
1076 enum { ARG_VALUE = 1 };
1077
1078public:
1079 Value *getValue() const {
1080 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1081 }
1082 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1083 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1084
1085 void setValue(Value *Val) {
1086 assert(getValue()->getType() == Val->getType() &&
1087 "setValue called with value of wrong type!");
1088 BaseCL::setArgOperand(ARG_VALUE, Val);
1089 }
1090};
1091
1092/// This is the common base class for memset/memcpy/memmove.
1093class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1094private:
1095 enum { ARG_VOLATILE = 3 };
1096
1097public:
1099 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1100 }
1101
1102 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1103
1104 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1105
1106 bool isForceInlined() const {
1107 switch (getIntrinsicID()) {
1108 case Intrinsic::memset_inline:
1109 case Intrinsic::memcpy_inline:
1110 return true;
1111 default:
1112 return false;
1113 }
1114 }
1115
1116 // Methods for support type inquiry through isa, cast, and dyn_cast:
1117 static bool classof(const IntrinsicInst *I) {
1118 switch (I->getIntrinsicID()) {
1119 case Intrinsic::memcpy:
1120 case Intrinsic::memmove:
1121 case Intrinsic::memset:
1122 case Intrinsic::memset_inline:
1123 case Intrinsic::memcpy_inline:
1124 return true;
1125 default:
1126 return false;
1127 }
1128 }
1129 static bool classof(const Value *V) {
1131 }
1132};
1133
1134/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1135class MemSetInst : public MemSetBase<MemIntrinsic> {
1136public:
1137 // Methods for support type inquiry through isa, cast, and dyn_cast:
1138 static bool classof(const IntrinsicInst *I) {
1139 switch (I->getIntrinsicID()) {
1140 case Intrinsic::memset:
1141 case Intrinsic::memset_inline:
1142 return true;
1143 default:
1144 return false;
1145 }
1146 }
1147 static bool classof(const Value *V) {
1149 }
1150};
1151
1152/// This class wraps the llvm.experimental.memset.pattern intrinsic.
1153/// Note that despite the inheritance, this is not part of the
1154/// MemIntrinsic hierachy in terms of isa/cast.
1155class MemSetPatternInst : public MemSetBase<MemIntrinsic> {
1156private:
1157 enum { ARG_VOLATILE = 3 };
1158
1159public:
1161 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1162 }
1163
1164 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1165
1166 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1167
1168 // Methods for support type inquiry through isa, cast, and dyn_cast:
1169 static bool classof(const IntrinsicInst *I) {
1170 return I->getIntrinsicID() == Intrinsic::experimental_memset_pattern;
1171 }
1172 static bool classof(const Value *V) {
1174 }
1175};
1176
1177/// This class wraps the llvm.memcpy/memmove intrinsics.
1178class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1179public:
1180 // Methods for support type inquiry through isa, cast, and dyn_cast:
1181 static bool classof(const IntrinsicInst *I) {
1182 switch (I->getIntrinsicID()) {
1183 case Intrinsic::memcpy:
1184 case Intrinsic::memmove:
1185 case Intrinsic::memcpy_inline:
1186 return true;
1187 default:
1188 return false;
1189 }
1190 }
1191 static bool classof(const Value *V) {
1193 }
1194};
1195
1196/// This class wraps the llvm.memcpy intrinsic.
1198public:
1199 // Methods for support type inquiry through isa, cast, and dyn_cast:
1200 static bool classof(const IntrinsicInst *I) {
1201 return I->getIntrinsicID() == Intrinsic::memcpy ||
1202 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1203 }
1204 static bool classof(const Value *V) {
1206 }
1207};
1208
1209/// This class wraps the llvm.memmove intrinsic.
1211public:
1212 // Methods for support type inquiry through isa, cast, and dyn_cast:
1213 static bool classof(const IntrinsicInst *I) {
1214 return I->getIntrinsicID() == Intrinsic::memmove;
1215 }
1216 static bool classof(const Value *V) {
1218 }
1219};
1220
1221// The common base class for any memset/memmove/memcpy intrinsics;
1222// whether they be atomic or non-atomic.
1223// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1224// and llvm.memset/memcpy/memmove
1225class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1226private:
1227 enum { ARG_ELEMENTSIZE = 3 };
1228
1229public:
1230 bool isVolatile() const {
1231 // Only the non-atomic intrinsics can be volatile
1232 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1233 return MI->isVolatile();
1234 return false;
1235 }
1236
1237 bool isAtomic() const {
1238 switch (getIntrinsicID()) {
1239 case Intrinsic::memcpy_element_unordered_atomic:
1240 case Intrinsic::memmove_element_unordered_atomic:
1241 case Intrinsic::memset_element_unordered_atomic:
1242 return true;
1243 default:
1244 return false;
1245 }
1246 }
1247
1248 static bool classof(const IntrinsicInst *I) {
1249 switch (I->getIntrinsicID()) {
1250 case Intrinsic::memcpy:
1251 case Intrinsic::memcpy_inline:
1252 case Intrinsic::memmove:
1253 case Intrinsic::memset:
1254 case Intrinsic::memset_inline:
1255 case Intrinsic::memcpy_element_unordered_atomic:
1256 case Intrinsic::memmove_element_unordered_atomic:
1257 case Intrinsic::memset_element_unordered_atomic:
1258 return true;
1259 default:
1260 return false;
1261 }
1262 }
1263 static bool classof(const Value *V) {
1265 }
1266
1268 assert(isAtomic());
1269 return getArgOperand(ARG_ELEMENTSIZE);
1270 }
1271
1273 assert(isAtomic());
1274 return cast<ConstantInt>(getRawElementSizeInBytes())->getZExtValue();
1275 }
1276};
1277
1278/// This class represents any memset intrinsic
1279// i.e. llvm.element.unordered.atomic.memset
1280// and llvm.memset
1281class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1282public:
1283 static bool classof(const IntrinsicInst *I) {
1284 switch (I->getIntrinsicID()) {
1285 case Intrinsic::memset:
1286 case Intrinsic::memset_inline:
1287 case Intrinsic::memset_element_unordered_atomic:
1288 return true;
1289 default:
1290 return false;
1291 }
1292 }
1293 static bool classof(const Value *V) {
1295 }
1296};
1297
1298// This class wraps any memcpy/memmove intrinsics
1299// i.e. llvm.element.unordered.atomic.memcpy/memmove
1300// and llvm.memcpy/memmove
1301class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1302public:
1303 static bool classof(const IntrinsicInst *I) {
1304 switch (I->getIntrinsicID()) {
1305 case Intrinsic::memcpy:
1306 case Intrinsic::memcpy_inline:
1307 case Intrinsic::memmove:
1308 case Intrinsic::memcpy_element_unordered_atomic:
1309 case Intrinsic::memmove_element_unordered_atomic:
1310 return true;
1311 default:
1312 return false;
1313 }
1314 }
1315 static bool classof(const Value *V) {
1317 }
1318};
1319
1320/// This class represents any memcpy intrinsic
1321/// i.e. llvm.element.unordered.atomic.memcpy
1322/// and llvm.memcpy
1324public:
1325 static bool classof(const IntrinsicInst *I) {
1326 switch (I->getIntrinsicID()) {
1327 case Intrinsic::memcpy:
1328 case Intrinsic::memcpy_inline:
1329 case Intrinsic::memcpy_element_unordered_atomic:
1330 return true;
1331 default:
1332 return false;
1333 }
1334 }
1335 static bool classof(const Value *V) {
1337 }
1338};
1339
1340/// This class represents any memmove intrinsic
1341/// i.e. llvm.element.unordered.atomic.memmove
1342/// and llvm.memmove
1344public:
1345 static bool classof(const IntrinsicInst *I) {
1346 switch (I->getIntrinsicID()) {
1347 case Intrinsic::memmove:
1348 case Intrinsic::memmove_element_unordered_atomic:
1349 return true;
1350 default:
1351 return false;
1352 }
1353 }
1354 static bool classof(const Value *V) {
1356 }
1357};
1358
1359/// This represents the llvm.va_start intrinsic.
1361public:
1362 static bool classof(const IntrinsicInst *I) {
1363 return I->getIntrinsicID() == Intrinsic::vastart;
1364 }
1365 static bool classof(const Value *V) {
1367 }
1368
1369 Value *getArgList() const { return getArgOperand(0); }
1370};
1371
1372/// This represents the llvm.va_end intrinsic.
1373class VAEndInst : public IntrinsicInst {
1374public:
1375 static bool classof(const IntrinsicInst *I) {
1376 return I->getIntrinsicID() == Intrinsic::vaend;
1377 }
1378 static bool classof(const Value *V) {
1380 }
1381
1382 Value *getArgList() const { return getArgOperand(0); }
1383};
1384
1385/// This represents the llvm.va_copy intrinsic.
1387public:
1388 static bool classof(const IntrinsicInst *I) {
1389 return I->getIntrinsicID() == Intrinsic::vacopy;
1390 }
1391 static bool classof(const Value *V) {
1393 }
1394
1395 Value *getDest() const { return getArgOperand(0); }
1396 Value *getSrc() const { return getArgOperand(1); }
1397};
1398
1399/// A base class for all instrprof intrinsics.
1401protected:
1402 static bool isCounterBase(const IntrinsicInst &I) {
1403 switch (I.getIntrinsicID()) {
1404 case Intrinsic::instrprof_cover:
1405 case Intrinsic::instrprof_increment:
1406 case Intrinsic::instrprof_increment_step:
1407 case Intrinsic::instrprof_callsite:
1408 case Intrinsic::instrprof_timestamp:
1409 case Intrinsic::instrprof_value_profile:
1410 return true;
1411 }
1412 return false;
1413 }
1414 static bool isMCDCBitmapBase(const IntrinsicInst &I) {
1415 switch (I.getIntrinsicID()) {
1416 case Intrinsic::instrprof_mcdc_parameters:
1417 case Intrinsic::instrprof_mcdc_tvbitmap_update:
1418 return true;
1419 }
1420 return false;
1421 }
1422
1423public:
1424 static bool classof(const Value *V) {
1425 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1426 return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr);
1427 return false;
1428 }
1429
1430 // The name of the instrumented function, assuming it is a global variable.
1433 }
1434
1435 // The "name" operand of the profile instrumentation instruction - this is the
1436 // operand that can be used to relate the instruction to the function it
1437 // belonged to at instrumentation time.
1439
1441
1442 // The hash of the CFG for the instrumented function.
1444};
1445
1446/// A base class for all instrprof counter intrinsics.
1448public:
1449 static bool classof(const Value *V) {
1450 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1451 return InstrProfInstBase::isCounterBase(*Instr);
1452 return false;
1453 }
1454
1455 // The number of counters for the instrumented function.
1457 // The index of the counter that this instruction acts on.
1458 LLVM_ABI ConstantInt *getIndex() const;
1459 LLVM_ABI void setIndex(uint32_t Idx);
1460};
1461
1462/// This represents the llvm.instrprof.cover intrinsic.
1464public:
1465 static bool classof(const IntrinsicInst *I) {
1466 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1467 }
1468 static bool classof(const Value *V) {
1470 }
1471};
1472
1473/// This represents the llvm.instrprof.increment intrinsic.
1475public:
1476 static bool classof(const IntrinsicInst *I) {
1477 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1478 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1479 }
1480 static bool classof(const Value *V) {
1482 }
1483 LLVM_ABI Value *getStep() const;
1484};
1485
1486/// This represents the llvm.instrprof.increment.step intrinsic.
1488public:
1489 static bool classof(const IntrinsicInst *I) {
1490 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1491 }
1492 static bool classof(const Value *V) {
1494 }
1495};
1496
1497/// This represents the llvm.instrprof.callsite intrinsic.
1498/// It is structurally like the increment or step counters, hence the
1499/// inheritance relationship, albeit somewhat tenuous (it's not 'counting' per
1500/// se)
1502public:
1503 static bool classof(const IntrinsicInst *I) {
1504 return I->getIntrinsicID() == Intrinsic::instrprof_callsite;
1505 }
1506 static bool classof(const Value *V) {
1508 }
1509 // We instrument direct calls (but not to intrinsics), or indirect calls.
1510 static bool canInstrumentCallsite(const CallBase &CB) {
1511 return !CB.isInlineAsm() &&
1512 (CB.isIndirectCall() ||
1514 }
1515 LLVM_ABI Value *getCallee() const;
1516 LLVM_ABI void setCallee(Value *Callee);
1517};
1518
1519/// This represents the llvm.instrprof.timestamp intrinsic.
1521public:
1522 static bool classof(const IntrinsicInst *I) {
1523 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1524 }
1525 static bool classof(const Value *V) {
1527 }
1528};
1529
1530/// This represents the llvm.instrprof.value.profile intrinsic.
1532public:
1533 static bool classof(const IntrinsicInst *I) {
1534 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1535 }
1536 static bool classof(const Value *V) {
1538 }
1539
1541
1544 }
1545
1546 // Returns the value site index.
1548};
1549
1550/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1552public:
1553 static bool classof(const IntrinsicInst *I) {
1555 }
1556 static bool classof(const Value *V) {
1558 }
1559
1560 /// \return The number of bits used for the MCDC bitmaps for the instrumented
1561 /// function.
1565
1566 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1567 /// function.
1568 auto getNumBitmapBytes() const {
1569 return alignTo(getNumBitmapBits()->getZExtValue(), CHAR_BIT) / CHAR_BIT;
1570 }
1571};
1572
1573/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1575public:
1576 static bool classof(const IntrinsicInst *I) {
1577 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1578 }
1579 static bool classof(const Value *V) {
1581 }
1582};
1583
1584/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1586public:
1587 static bool classof(const IntrinsicInst *I) {
1588 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1589 }
1590 static bool classof(const Value *V) {
1592 }
1593
1594 /// \return The index of the TestVector Bitmap upon which this intrinsic
1595 /// acts.
1598 }
1599
1600 /// \return The address of the corresponding condition bitmap containing
1601 /// the index of the TestVector to update within the TestVector Bitmap.
1603};
1604
1606public:
1607 static bool classof(const IntrinsicInst *I) {
1608 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1609 }
1610
1611 static bool classof(const Value *V) {
1613 }
1614
1617 }
1618
1620
1623 }
1624
1626};
1627
1629public:
1630 static bool classof(const IntrinsicInst *I) {
1631 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1632 }
1633
1634 static bool classof(const Value *V) {
1636 }
1637
1639 auto *MV =
1641 return cast<MDNode>(MV->getMetadata());
1642 }
1643
1648};
1649
1650/// Common base class for representing values projected from a statepoint.
1651/// Currently, the only projections available are gc.result and gc.relocate.
1653public:
1654 static bool classof(const IntrinsicInst *I) {
1655 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1656 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1657 }
1658
1659 static bool classof(const Value *V) {
1661 }
1662
1663 /// Return true if this relocate is tied to the invoke statepoint.
1664 /// This includes relocates which are on the unwinding path.
1665 bool isTiedToInvoke() const {
1666 const Value *Token = getArgOperand(0);
1667
1668 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1669 }
1670
1671 /// The statepoint with which this gc.relocate is associated.
1672 LLVM_ABI const Value *getStatepoint() const;
1673};
1674
1675/// Represents calls to the gc.relocate intrinsic.
1677public:
1678 static bool classof(const IntrinsicInst *I) {
1679 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1680 }
1681
1682 static bool classof(const Value *V) {
1684 }
1685
1686 /// The index into the associate statepoint's argument list
1687 /// which contains the base pointer of the pointer whose
1688 /// relocation this gc.relocate describes.
1689 unsigned getBasePtrIndex() const {
1690 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1691 }
1692
1693 /// The index into the associate statepoint's argument list which
1694 /// contains the pointer whose relocation this gc.relocate describes.
1695 unsigned getDerivedPtrIndex() const {
1696 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1697 }
1698
1699 LLVM_ABI Value *getBasePtr() const;
1700 LLVM_ABI Value *getDerivedPtr() const;
1701};
1702
1703/// Represents calls to the gc.result intrinsic.
1705public:
1706 static bool classof(const IntrinsicInst *I) {
1707 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1708 }
1709
1710 static bool classof(const Value *V) {
1712 }
1713};
1714
1715
1716/// This represents the llvm.assume intrinsic.
1718public:
1719 static bool classof(const IntrinsicInst *I) {
1720 return I->getIntrinsicID() == Intrinsic::assume;
1721 }
1722 static bool classof(const Value *V) {
1724 }
1725};
1726
1727/// Check if \p ID corresponds to a convergence control intrinsic.
1728static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1729 switch (IntrinsicID) {
1730 default:
1731 return false;
1732 case Intrinsic::experimental_convergence_anchor:
1733 case Intrinsic::experimental_convergence_entry:
1734 case Intrinsic::experimental_convergence_loop:
1735 return true;
1736 }
1737}
1738
1739/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1741public:
1742 static bool classof(const IntrinsicInst *I) {
1743 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1744 }
1745
1746 static bool classof(const Value *V) {
1748 }
1749
1750 bool isAnchor() const {
1751 return getIntrinsicID() == Intrinsic::experimental_convergence_anchor;
1752 }
1753 bool isEntry() const {
1754 return getIntrinsicID() == Intrinsic::experimental_convergence_entry;
1755 }
1756 bool isLoop() const {
1757 return getIntrinsicID() == Intrinsic::experimental_convergence_loop;
1758 }
1759
1764};
1765
1767public:
1768 static bool classof(const IntrinsicInst *I) {
1769 return I->getIntrinsicID() == Intrinsic::structured_alloca;
1770 }
1771
1772 static bool classof(const Value *V) {
1774 }
1775
1777 return getRetAttr(Attribute::ElementType).getValueAsType();
1778 }
1779};
1780
1782public:
1783 static bool classof(const IntrinsicInst *I) {
1784 return I->getIntrinsicID() == Intrinsic::structured_gep;
1785 }
1786
1787 static bool classof(const Value *V) {
1789 }
1790
1791 static unsigned getPointerOperandIndex() { return 0; }
1792
1796
1798 return getParamAttr(0, Attribute::ElementType).getValueAsType();
1799 }
1800
1801 unsigned getNumIndices() const { return arg_size() - 1; }
1802
1803 Value *getIndexOperand(size_t Index) const {
1804 assert(Index < getNumIndices());
1805 return getOperand(Index + 1);
1806 }
1807
1809 return make_range(op_begin() + 1, op_begin() + 1 + getNumIndices());
1810 }
1811
1813 Type *CurrentType = getBaseType();
1814 for (unsigned I = 0; I < getNumIndices(); I++) {
1815 if (ArrayType *AT = dyn_cast<ArrayType>(CurrentType)) {
1816 CurrentType = AT->getElementType();
1817 } else if (VectorType *VT = dyn_cast<VectorType>(CurrentType)) {
1818 CurrentType = VT->getElementType();
1819 } else if (StructType *ST = dyn_cast<StructType>(CurrentType)) {
1821 CurrentType = ST->getElementType(CI->getZExtValue());
1822 } else {
1823 // FIXME(Keenuts): add testing reaching those places once initial
1824 // implementation has landed.
1825 llvm_unreachable("unimplemented");
1826 }
1827 }
1828
1829 return CurrentType;
1830 }
1831};
1832
1833} // end namespace llvm
1834
1835#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:203
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
Definition APInt.h:206
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
Definition APInt.h:213
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Definition APInt.h:216
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)
LLVM_ABI void setKillAddress()
Kill the address component.
LLVM_ABI bool isKillAddress() const
Check whether this kills the address component.
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)
void setAddressExpression(DIExpression *NewExpr)
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)
void setLabel(DILabel *NewLabel)
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...
void setVariable(DILocalVariable *NewVar)
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 void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
bool isValueOfVariable() const
Determine if this describes the value of a local variable.
void setRawLocation(Metadata *Location)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
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
bool isAddressOfVariable() const
Does this describe the address of a local variable.
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:1069
LLVMContext & getContext() const
Definition Metadata.h:1233
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)
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:111
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:67
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...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
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:459
Value * getValue() const
Definition Metadata.h:499
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:255
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition Value.cpp:713
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:43
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:1746
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:144
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:106