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 LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
328 /// Adding a new location operand will always result in this intrinsic using
329 /// an ArgList, and must always be accompanied by a new expression that uses
330 /// the new operand.
333
335 setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
336 }
337
341
345
346 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
347
348 /// Does this describe the address of a local variable. True for dbg.declare,
349 /// but not dbg.value, which describes its value, or dbg.assign, which
350 /// describes a combination of the variable's value and address.
351 bool isAddressOfVariable() const {
352 return getIntrinsicID() == Intrinsic::dbg_declare;
353 }
354
355 /// Determine if this describes the value of a local variable. It is true for
356 /// dbg.value, but false for dbg.declare, which describes its address, and
357 /// false for dbg.assign, which describes a combination of the variable's
358 /// value and address.
359 bool isValueOfVariable() const {
360 return getIntrinsicID() == Intrinsic::dbg_value;
361 }
362
364 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
365 // this set anymore.
366 SmallPtrSet<Value *, 4> RemovedValues;
367 for (Value *OldValue : location_ops()) {
368 if (!RemovedValues.insert(OldValue).second)
369 continue;
370 Value *Poison = PoisonValue::get(OldValue->getType());
372 }
373 }
374
375 bool isKillLocation() const {
377 }
378
382
386
388 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
389 }
390
394
396 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
397 }
398
400 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
401 }
402
403 /// Use of this should generally be avoided; instead,
404 /// replaceVariableLocationOp and addVariableLocationOps should be used where
405 /// possible to avoid creating invalid state.
406 void setRawLocation(Metadata *Location) {
407 return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
408 }
409
410 /// Get the size (in bits) of the variable, or fragment of the variable that
411 /// is described.
412 LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
413
414 /// Get the FragmentInfo for the variable.
415 std::optional<DIExpression::FragmentInfo> getFragment() const {
416 return getExpression()->getFragmentInfo();
417 }
418
419 /// Get the FragmentInfo for the variable if it exists, otherwise return a
420 /// FragmentInfo that covers the entire variable if the variable size is
421 /// known, otherwise return a zero-sized fragment.
423 DIExpression::FragmentInfo VariableSlice(0, 0);
424 // Get the fragment or variable size, or zero.
425 if (auto Sz = getFragmentSizeInBits())
426 VariableSlice.SizeInBits = *Sz;
427 if (auto Frag = getExpression()->getFragmentInfo())
428 VariableSlice.OffsetInBits = Frag->OffsetInBits;
429 return VariableSlice;
430 }
431
432 /// \name Casting methods
433 /// @{
434 static bool classof(const IntrinsicInst *I) {
435 switch (I->getIntrinsicID()) {
436 case Intrinsic::dbg_declare:
437 case Intrinsic::dbg_value:
438 case Intrinsic::dbg_assign:
439 return true;
440 default:
441 return false;
442 }
443 }
444 static bool classof(const Value *V) {
446 }
447 /// @}
448protected:
449 void setArgOperand(unsigned i, Value *v) {
451 }
452 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
453};
454
455/// This represents the llvm.dbg.declare instruction.
457public:
458 Value *getAddress() const {
460 "dbg.declare must have exactly 1 location operand.");
461 return getVariableLocationOp(0);
462 }
463
464 /// \name Casting methods
465 /// @{
466 static bool classof(const IntrinsicInst *I) {
467 return I->getIntrinsicID() == Intrinsic::dbg_declare;
468 }
469 static bool classof(const Value *V) {
471 }
472 /// @}
473};
474
475/// This represents the llvm.dbg.value instruction.
477public:
478 // The default argument should only be used in ISel, and the default option
479 // should be removed once ISel support for multiple location ops is complete.
480 Value *getValue(unsigned OpIdx = 0) const {
481 return getVariableLocationOp(OpIdx);
482 }
486
487 /// \name Casting methods
488 /// @{
489 static bool classof(const IntrinsicInst *I) {
490 return I->getIntrinsicID() == Intrinsic::dbg_value ||
491 I->getIntrinsicID() == Intrinsic::dbg_assign;
492 }
493 static bool classof(const Value *V) {
495 }
496 /// @}
497};
498
499/// This represents the llvm.dbg.assign instruction.
501 enum Operands {
502 OpValue,
503 OpVar,
504 OpExpr,
505 OpAssignID,
506 OpAddress,
507 OpAddressExpr,
508 };
509
510public:
511 LLVM_ABI Value *getAddress() const;
513 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
514 }
516 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
517 }
520 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
521 }
526 setArgOperand(OpAddressExpr,
527 MetadataAsValue::get(NewExpr->getContext(), NewExpr));
528 }
530 LLVM_ABI void setAddress(Value *V);
531 /// Kill the address component.
533 /// Check whether this kills the address component. This doesn't take into
534 /// account the position of the intrinsic, therefore a returned value of false
535 /// does not guarentee the address is a valid location for the variable at the
536 /// intrinsic's position in IR.
537 LLVM_ABI bool isKillAddress() const;
538 LLVM_ABI void setValue(Value *V);
539 /// \name Casting methods
540 /// @{
541 static bool classof(const IntrinsicInst *I) {
542 return I->getIntrinsicID() == Intrinsic::dbg_assign;
543 }
544 static bool classof(const Value *V) {
546 }
547 /// @}
548};
549
550/// This represents the llvm.dbg.label instruction.
552public:
554 void setLabel(DILabel *NewLabel) {
556 }
557
559 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
560 }
561
562 /// Methods for support type inquiry through isa, cast, and dyn_cast:
563 /// @{
564 static bool classof(const IntrinsicInst *I) {
565 return I->getIntrinsicID() == Intrinsic::dbg_label;
566 }
567 static bool classof(const Value *V) {
569 }
570 /// @}
571};
572
573/// This is the common base class for vector predication intrinsics.
575public:
576 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
577 /// \p Params. Additionally, the load and gather intrinsics require
578 /// \p ReturnType to be specified.
579 LLVM_ABI static Function *
581 ArrayRef<Value *> Params);
582
583 LLVM_ABI static std::optional<unsigned>
584 getMaskParamPos(Intrinsic::ID IntrinsicID);
585 LLVM_ABI static std::optional<unsigned>
587
588 // Whether \p ID is a VP intrinsic ID.
590
591 /// \return The mask parameter or nullptr.
592 LLVM_ABI Value *getMaskParam() const;
594
595 /// \return The vector length parameter or nullptr.
598
599 /// \return Whether the vector length param can be ignored.
601
602 /// \return The static element count (vector number of elements) the vector
603 /// length parameter applies to.
605
606 /// \return The alignment of the pointer used by this load/store/gather or
607 /// scatter.
609 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
610
611 /// \return The pointer operand of this load,store, gather or scatter.
613 LLVM_ABI static std::optional<unsigned>
615
616 /// \return The data (payload) operand of this store or scatter.
618 LLVM_ABI static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
619
620 // Methods for support type inquiry through isa, cast, and dyn_cast:
621 static bool classof(const IntrinsicInst *I) {
622 return isVPIntrinsic(I->getIntrinsicID());
623 }
624 static bool classof(const Value *V) {
626 }
627
628 // Equivalent non-predicated opcode
629 std::optional<unsigned> getFunctionalOpcode() const {
631 }
632
633 // Equivalent non-predicated intrinsic ID
634 std::optional<unsigned> getFunctionalIntrinsicID() const {
636 }
637
638 // Equivalent non-predicated opcode
639 LLVM_ABI static std::optional<unsigned>
641
642 // Equivalent non-predicated intrinsic ID
643 LLVM_ABI static std::optional<Intrinsic::ID>
645};
646
647/// This represents vector predication reduction intrinsics.
649public:
650 LLVM_ABI static bool isVPReduction(Intrinsic::ID ID);
651
652 LLVM_ABI unsigned getStartParamPos() const;
653 LLVM_ABI unsigned getVectorParamPos() const;
654
655 LLVM_ABI static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
656 LLVM_ABI static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
657
658 /// Methods for support type inquiry through isa, cast, and dyn_cast:
659 /// @{
660 static bool classof(const IntrinsicInst *I) {
661 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
662 }
663 static bool classof(const Value *V) {
665 }
666 /// @}
667};
668
669/// This is the common base class for constrained floating point intrinsics.
671public:
672 LLVM_ABI unsigned getNonMetadataArgCount() const;
673 LLVM_ABI std::optional<RoundingMode> getRoundingMode() const;
674 LLVM_ABI std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
675 LLVM_ABI bool isDefaultFPEnvironment() const;
676
677 // Methods for support type inquiry through isa, cast, and dyn_cast:
678 LLVM_ABI static bool classof(const IntrinsicInst *I);
679 static bool classof(const Value *V) {
681 }
682};
683
684/// Constrained floating point compare intrinsics.
686public:
688 bool isSignaling() const {
689 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
690 }
691
692 // Methods for support type inquiry through isa, cast, and dyn_cast:
693 static bool classof(const IntrinsicInst *I) {
694 switch (I->getIntrinsicID()) {
695 case Intrinsic::experimental_constrained_fcmp:
696 case Intrinsic::experimental_constrained_fcmps:
697 return true;
698 default:
699 return false;
700 }
701 }
702 static bool classof(const Value *V) {
704 }
705};
706
707/// This class represents min/max intrinsics.
709public:
710 static bool classof(const IntrinsicInst *I) {
711 switch (I->getIntrinsicID()) {
712 case Intrinsic::umin:
713 case Intrinsic::umax:
714 case Intrinsic::smin:
715 case Intrinsic::smax:
716 return true;
717 default:
718 return false;
719 }
720 }
721 static bool classof(const Value *V) {
723 }
724
725 Value *getLHS() const { return getArgOperand(0); }
726 Value *getRHS() const { return getArgOperand(1); }
727
728 /// Returns the comparison predicate underlying the intrinsic.
730 switch (ID) {
731 case Intrinsic::umin:
733 case Intrinsic::umax:
735 case Intrinsic::smin:
737 case Intrinsic::smax:
739 default:
740 llvm_unreachable("Invalid intrinsic");
741 }
742 }
743
744 /// Returns the comparison predicate underlying the intrinsic.
748
749 /// Whether the intrinsic is signed or unsigned.
750 static bool isSigned(Intrinsic::ID ID) {
752 };
753
754 /// Whether the intrinsic is signed or unsigned.
755 bool isSigned() const { return isSigned(getIntrinsicID()); };
756
757 /// Whether the intrinsic is a smin or umin.
758 static bool isMin(Intrinsic::ID ID) {
759 switch (ID) {
760 case Intrinsic::umin:
761 case Intrinsic::smin:
762 return true;
763 case Intrinsic::umax:
764 case Intrinsic::smax:
765 return false;
766 default:
767 llvm_unreachable("Invalid intrinsic");
768 }
769 }
770
771 /// Whether the intrinsic is a smin or a umin.
772 bool isMin() const { return isMin(getIntrinsicID()); }
773
774 /// Whether the intrinsic is a smax or a umax.
775 bool isMax() const { return !isMin(getIntrinsicID()); }
776
777 /// Returns the identity value for this min/max intrinsic, such
778 /// that minmax(X, Identity) == X.
779 static APInt getIdentity(Intrinsic::ID ID, unsigned NumBits) {
780 switch (ID) {
781 case Intrinsic::umin:
782 return APInt::getMaxValue(NumBits);
783 case Intrinsic::umax:
784 return APInt::getMinValue(NumBits);
785 case Intrinsic::smin:
786 return APInt::getSignedMaxValue(NumBits);
787 case Intrinsic::smax:
788 return APInt::getSignedMinValue(NumBits);
789 default:
790 llvm_unreachable("Invalid intrinsic");
791 }
792 }
793
794 /// Returns the identity value for this min/max intrinsic, such
795 /// that minmax(X, Identity) == X.
799
800 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
801 /// so there is a certain threshold value, upon reaching which,
802 /// their value can no longer change. Return said threshold.
803 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
804 switch (ID) {
805 case Intrinsic::umin:
806 return APInt::getMinValue(numBits);
807 case Intrinsic::umax:
808 return APInt::getMaxValue(numBits);
809 case Intrinsic::smin:
810 return APInt::getSignedMinValue(numBits);
811 case Intrinsic::smax:
812 return APInt::getSignedMaxValue(numBits);
813 default:
814 llvm_unreachable("Invalid intrinsic");
815 }
816 }
817
818 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
819 /// so there is a certain threshold value, upon reaching which,
820 /// their value can no longer change. Return said threshold.
821 APInt getSaturationPoint(unsigned numBits) const {
822 return getSaturationPoint(getIntrinsicID(), numBits);
823 }
824
825 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
826 /// so there is a certain threshold value, upon reaching which,
827 /// their value can no longer change. Return said threshold.
830 Ty, getSaturationPoint(ID, Ty->getScalarSizeInBits()));
831 }
832
833 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
834 /// so there is a certain threshold value, upon reaching which,
835 /// their value can no longer change. Return said threshold.
838 }
839};
840
841/// This class represents a ucmp/scmp intrinsic
843public:
844 static bool classof(const IntrinsicInst *I) {
845 switch (I->getIntrinsicID()) {
846 case Intrinsic::scmp:
847 case Intrinsic::ucmp:
848 return true;
849 default:
850 return false;
851 }
852 }
853 static bool classof(const Value *V) {
855 }
856
857 Value *getLHS() const { return getArgOperand(0); }
858 Value *getRHS() const { return getArgOperand(1); }
859
860 static bool isSigned(Intrinsic::ID ID) { return ID == Intrinsic::scmp; }
861 bool isSigned() const { return isSigned(getIntrinsicID()); }
862
869
876};
877
878/// This class represents an intrinsic that is based on a binary operation.
879/// This includes op.with.overflow and saturating add/sub intrinsics.
881public:
882 static bool classof(const IntrinsicInst *I) {
883 switch (I->getIntrinsicID()) {
884 case Intrinsic::uadd_with_overflow:
885 case Intrinsic::sadd_with_overflow:
886 case Intrinsic::usub_with_overflow:
887 case Intrinsic::ssub_with_overflow:
888 case Intrinsic::umul_with_overflow:
889 case Intrinsic::smul_with_overflow:
890 case Intrinsic::uadd_sat:
891 case Intrinsic::sadd_sat:
892 case Intrinsic::usub_sat:
893 case Intrinsic::ssub_sat:
894 return true;
895 default:
896 return false;
897 }
898 }
899 static bool classof(const Value *V) {
901 }
902
903 Value *getLHS() const { return getArgOperand(0); }
904 Value *getRHS() const { return getArgOperand(1); }
905
906 /// Returns the binary operation underlying the intrinsic.
908
909 /// Whether the intrinsic is signed or unsigned.
910 LLVM_ABI bool isSigned() const;
911
912 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
913 LLVM_ABI unsigned getNoWrapKind() const;
914};
915
916/// Represents an op.with.overflow intrinsic.
918public:
919 static bool classof(const IntrinsicInst *I) {
920 switch (I->getIntrinsicID()) {
921 case Intrinsic::uadd_with_overflow:
922 case Intrinsic::sadd_with_overflow:
923 case Intrinsic::usub_with_overflow:
924 case Intrinsic::ssub_with_overflow:
925 case Intrinsic::umul_with_overflow:
926 case Intrinsic::smul_with_overflow:
927 return true;
928 default:
929 return false;
930 }
931 }
932 static bool classof(const Value *V) {
934 }
935};
936
937/// Represents a saturating add/sub intrinsic.
939public:
940 static bool classof(const IntrinsicInst *I) {
941 switch (I->getIntrinsicID()) {
942 case Intrinsic::uadd_sat:
943 case Intrinsic::sadd_sat:
944 case Intrinsic::usub_sat:
945 case Intrinsic::ssub_sat:
946 return true;
947 default:
948 return false;
949 }
950 }
951 static bool classof(const Value *V) {
953 }
954};
955
956/// Common base class for all memory intrinsics. Simply provides
957/// common methods.
958/// Written as CRTP to avoid a common base class amongst the
959/// three atomicity hierarchies.
960template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
961private:
962 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
963
964public:
965 Value *getRawDest() const {
966 return const_cast<Value *>(getArgOperand(ARG_DEST));
967 }
968 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
969 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
970
971 Value *getLength() const {
972 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
973 }
974 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
975 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
976
977 std::optional<APInt> getLengthInBytes() const {
979 if (!C)
980 return std::nullopt;
981 return C->getValue();
982 }
983
984 /// This is just like getRawDest, but it strips off any cast
985 /// instructions (including addrspacecast) that feed it, giving the
986 /// original input. The returned value is guaranteed to be a pointer.
987 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
988
989 unsigned getDestAddressSpace() const {
990 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
991 }
992
993 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
994
995 /// Set the specified arguments of the instruction.
996 void setDest(Value *Ptr) {
997 assert(getRawDest()->getType() == Ptr->getType() &&
998 "setDest called with pointer of wrong type!");
999 setArgOperand(ARG_DEST, Ptr);
1000 }
1001
1003 removeParamAttr(ARG_DEST, Attribute::Alignment);
1004 if (Alignment)
1005 addParamAttr(ARG_DEST,
1007 }
1008 void setDestAlignment(Align Alignment) {
1009 removeParamAttr(ARG_DEST, Attribute::Alignment);
1010 addParamAttr(ARG_DEST,
1012 }
1013
1014 void setLength(Value *L) {
1015 assert(getLength()->getType() == L->getType() &&
1016 "setLength called with value of wrong type!");
1017 setArgOperand(ARG_LENGTH, L);
1018 }
1019
1021 setLength(ConstantInt::get(getLength()->getType(), L));
1022 }
1023};
1024
1025/// Common base class for all memory transfer intrinsics. Simply provides
1026/// common methods.
1027template <class BaseCL> class MemTransferBase : public BaseCL {
1028private:
1029 enum { ARG_SOURCE = 1 };
1030
1031public:
1032 /// Return the arguments to the instruction.
1034 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
1035 }
1036 const Use &getRawSourceUse() const {
1037 return BaseCL::getArgOperandUse(ARG_SOURCE);
1038 }
1039 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
1040
1041 /// This is just like getRawSource, but it strips off any cast
1042 /// instructions that feed it, giving the original input. The returned
1043 /// value is guaranteed to be a pointer.
1045
1046 unsigned getSourceAddressSpace() const {
1047 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
1048 }
1049
1051 return BaseCL::getParamAlign(ARG_SOURCE);
1052 }
1053
1054 void setSource(Value *Ptr) {
1055 assert(getRawSource()->getType() == Ptr->getType() &&
1056 "setSource called with pointer of wrong type!");
1057 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1058 }
1059
1061 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1062 if (Alignment)
1063 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1064 BaseCL::getContext(), *Alignment));
1065 }
1066
1067 void setSourceAlignment(Align Alignment) {
1068 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1069 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1070 BaseCL::getContext(), Alignment));
1071 }
1072};
1073
1074/// Common base class for all memset intrinsics. Simply provides
1075/// common methods.
1076template <class BaseCL> class MemSetBase : public BaseCL {
1077private:
1078 enum { ARG_VALUE = 1 };
1079
1080public:
1081 Value *getValue() const {
1082 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1083 }
1084 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1085 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1086
1087 void setValue(Value *Val) {
1088 assert(getValue()->getType() == Val->getType() &&
1089 "setValue called with value of wrong type!");
1090 BaseCL::setArgOperand(ARG_VALUE, Val);
1091 }
1092};
1093
1094/// This is the common base class for memset/memcpy/memmove.
1095class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1096private:
1097 enum { ARG_VOLATILE = 3 };
1098
1099public:
1101 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1102 }
1103
1104 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1105
1106 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1107
1108 bool isForceInlined() const {
1109 switch (getIntrinsicID()) {
1110 case Intrinsic::memset_inline:
1111 case Intrinsic::memcpy_inline:
1112 return true;
1113 default:
1114 return false;
1115 }
1116 }
1117
1118 // Methods for support type inquiry through isa, cast, and dyn_cast:
1119 static bool classof(const IntrinsicInst *I) {
1120 switch (I->getIntrinsicID()) {
1121 case Intrinsic::memcpy:
1122 case Intrinsic::memmove:
1123 case Intrinsic::memset:
1124 case Intrinsic::memset_inline:
1125 case Intrinsic::memcpy_inline:
1126 return true;
1127 default:
1128 return false;
1129 }
1130 }
1131 static bool classof(const Value *V) {
1133 }
1134};
1135
1136/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1137class MemSetInst : public MemSetBase<MemIntrinsic> {
1138public:
1139 // Methods for support type inquiry through isa, cast, and dyn_cast:
1140 static bool classof(const IntrinsicInst *I) {
1141 switch (I->getIntrinsicID()) {
1142 case Intrinsic::memset:
1143 case Intrinsic::memset_inline:
1144 return true;
1145 default:
1146 return false;
1147 }
1148 }
1149 static bool classof(const Value *V) {
1151 }
1152};
1153
1154/// This class wraps the llvm.experimental.memset.pattern intrinsic.
1155/// Note that despite the inheritance, this is not part of the
1156/// MemIntrinsic hierachy in terms of isa/cast.
1157class MemSetPatternInst : public MemSetBase<MemIntrinsic> {
1158private:
1159 enum { ARG_VOLATILE = 3 };
1160
1161public:
1163 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1164 }
1165
1166 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1167
1168 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1169
1170 // Methods for support type inquiry through isa, cast, and dyn_cast:
1171 static bool classof(const IntrinsicInst *I) {
1172 return I->getIntrinsicID() == Intrinsic::experimental_memset_pattern;
1173 }
1174 static bool classof(const Value *V) {
1176 }
1177};
1178
1179/// This class wraps the llvm.memcpy/memmove intrinsics.
1180class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1181public:
1182 // Methods for support type inquiry through isa, cast, and dyn_cast:
1183 static bool classof(const IntrinsicInst *I) {
1184 switch (I->getIntrinsicID()) {
1185 case Intrinsic::memcpy:
1186 case Intrinsic::memmove:
1187 case Intrinsic::memcpy_inline:
1188 return true;
1189 default:
1190 return false;
1191 }
1192 }
1193 static bool classof(const Value *V) {
1195 }
1196};
1197
1198/// This class wraps the llvm.memcpy intrinsic.
1200public:
1201 // Methods for support type inquiry through isa, cast, and dyn_cast:
1202 static bool classof(const IntrinsicInst *I) {
1203 return I->getIntrinsicID() == Intrinsic::memcpy ||
1204 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1205 }
1206 static bool classof(const Value *V) {
1208 }
1209};
1210
1211/// This class wraps the llvm.memmove intrinsic.
1213public:
1214 // Methods for support type inquiry through isa, cast, and dyn_cast:
1215 static bool classof(const IntrinsicInst *I) {
1216 return I->getIntrinsicID() == Intrinsic::memmove;
1217 }
1218 static bool classof(const Value *V) {
1220 }
1221};
1222
1223// The common base class for any memset/memmove/memcpy intrinsics;
1224// whether they be atomic or non-atomic.
1225// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1226// and llvm.memset/memcpy/memmove
1227class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1228private:
1229 enum { ARG_ELEMENTSIZE = 3 };
1230
1231public:
1232 bool isVolatile() const {
1233 // Only the non-atomic intrinsics can be volatile
1234 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1235 return MI->isVolatile();
1236 return false;
1237 }
1238
1239 bool isAtomic() const {
1240 switch (getIntrinsicID()) {
1241 case Intrinsic::memcpy_element_unordered_atomic:
1242 case Intrinsic::memmove_element_unordered_atomic:
1243 case Intrinsic::memset_element_unordered_atomic:
1244 return true;
1245 default:
1246 return false;
1247 }
1248 }
1249
1250 static bool classof(const IntrinsicInst *I) {
1251 switch (I->getIntrinsicID()) {
1252 case Intrinsic::memcpy:
1253 case Intrinsic::memcpy_inline:
1254 case Intrinsic::memmove:
1255 case Intrinsic::memset:
1256 case Intrinsic::memset_inline:
1257 case Intrinsic::memcpy_element_unordered_atomic:
1258 case Intrinsic::memmove_element_unordered_atomic:
1259 case Intrinsic::memset_element_unordered_atomic:
1260 return true;
1261 default:
1262 return false;
1263 }
1264 }
1265 static bool classof(const Value *V) {
1267 }
1268
1270 assert(isAtomic());
1271 return getArgOperand(ARG_ELEMENTSIZE);
1272 }
1273
1275 assert(isAtomic());
1276 return cast<ConstantInt>(getRawElementSizeInBytes())->getZExtValue();
1277 }
1278};
1279
1280/// This class represents any memset intrinsic
1281// i.e. llvm.element.unordered.atomic.memset
1282// and llvm.memset
1283class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1284public:
1285 static bool classof(const IntrinsicInst *I) {
1286 switch (I->getIntrinsicID()) {
1287 case Intrinsic::memset:
1288 case Intrinsic::memset_inline:
1289 case Intrinsic::memset_element_unordered_atomic:
1290 return true;
1291 default:
1292 return false;
1293 }
1294 }
1295 static bool classof(const Value *V) {
1297 }
1298};
1299
1300// This class wraps any memcpy/memmove intrinsics
1301// i.e. llvm.element.unordered.atomic.memcpy/memmove
1302// and llvm.memcpy/memmove
1303class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1304public:
1305 static bool classof(const IntrinsicInst *I) {
1306 switch (I->getIntrinsicID()) {
1307 case Intrinsic::memcpy:
1308 case Intrinsic::memcpy_inline:
1309 case Intrinsic::memmove:
1310 case Intrinsic::memcpy_element_unordered_atomic:
1311 case Intrinsic::memmove_element_unordered_atomic:
1312 return true;
1313 default:
1314 return false;
1315 }
1316 }
1317 static bool classof(const Value *V) {
1319 }
1320};
1321
1322/// This class represents any memcpy intrinsic
1323/// i.e. llvm.element.unordered.atomic.memcpy
1324/// and llvm.memcpy
1326public:
1327 static bool classof(const IntrinsicInst *I) {
1328 switch (I->getIntrinsicID()) {
1329 case Intrinsic::memcpy:
1330 case Intrinsic::memcpy_inline:
1331 case Intrinsic::memcpy_element_unordered_atomic:
1332 return true;
1333 default:
1334 return false;
1335 }
1336 }
1337 static bool classof(const Value *V) {
1339 }
1340};
1341
1342/// This class represents any memmove intrinsic
1343/// i.e. llvm.element.unordered.atomic.memmove
1344/// and llvm.memmove
1346public:
1347 static bool classof(const IntrinsicInst *I) {
1348 switch (I->getIntrinsicID()) {
1349 case Intrinsic::memmove:
1350 case Intrinsic::memmove_element_unordered_atomic:
1351 return true;
1352 default:
1353 return false;
1354 }
1355 }
1356 static bool classof(const Value *V) {
1358 }
1359};
1360
1361/// This represents the llvm.va_start intrinsic.
1363public:
1364 static bool classof(const IntrinsicInst *I) {
1365 return I->getIntrinsicID() == Intrinsic::vastart;
1366 }
1367 static bool classof(const Value *V) {
1369 }
1370
1371 Value *getArgList() const { return getArgOperand(0); }
1372};
1373
1374/// This represents the llvm.va_end intrinsic.
1375class VAEndInst : public IntrinsicInst {
1376public:
1377 static bool classof(const IntrinsicInst *I) {
1378 return I->getIntrinsicID() == Intrinsic::vaend;
1379 }
1380 static bool classof(const Value *V) {
1382 }
1383
1384 Value *getArgList() const { return getArgOperand(0); }
1385};
1386
1387/// This represents the llvm.va_copy intrinsic.
1389public:
1390 static bool classof(const IntrinsicInst *I) {
1391 return I->getIntrinsicID() == Intrinsic::vacopy;
1392 }
1393 static bool classof(const Value *V) {
1395 }
1396
1397 Value *getDest() const { return getArgOperand(0); }
1398 Value *getSrc() const { return getArgOperand(1); }
1399};
1400
1401/// A base class for all instrprof intrinsics.
1403protected:
1404 static bool isCounterBase(const IntrinsicInst &I) {
1405 switch (I.getIntrinsicID()) {
1406 case Intrinsic::instrprof_cover:
1407 case Intrinsic::instrprof_increment:
1408 case Intrinsic::instrprof_increment_step:
1409 case Intrinsic::instrprof_callsite:
1410 case Intrinsic::instrprof_timestamp:
1411 case Intrinsic::instrprof_value_profile:
1412 return true;
1413 }
1414 return false;
1415 }
1416 static bool isMCDCBitmapBase(const IntrinsicInst &I) {
1417 switch (I.getIntrinsicID()) {
1418 case Intrinsic::instrprof_mcdc_parameters:
1419 case Intrinsic::instrprof_mcdc_tvbitmap_update:
1420 return true;
1421 }
1422 return false;
1423 }
1424
1425public:
1426 static bool classof(const Value *V) {
1427 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1428 return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr);
1429 return false;
1430 }
1431
1432 // The name of the instrumented function, assuming it is a global variable.
1435 }
1436
1437 // The "name" operand of the profile instrumentation instruction - this is the
1438 // operand that can be used to relate the instruction to the function it
1439 // belonged to at instrumentation time.
1441
1443
1444 // The hash of the CFG for the instrumented function.
1446};
1447
1448/// A base class for all instrprof counter intrinsics.
1450public:
1451 static bool classof(const Value *V) {
1452 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1453 return InstrProfInstBase::isCounterBase(*Instr);
1454 return false;
1455 }
1456
1457 // The number of counters for the instrumented function.
1459 // The index of the counter that this instruction acts on.
1460 LLVM_ABI ConstantInt *getIndex() const;
1461 LLVM_ABI void setIndex(uint32_t Idx);
1462};
1463
1464/// This represents the llvm.instrprof.cover intrinsic.
1466public:
1467 static bool classof(const IntrinsicInst *I) {
1468 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1469 }
1470 static bool classof(const Value *V) {
1472 }
1473};
1474
1475/// This represents the llvm.instrprof.increment intrinsic.
1477public:
1478 static bool classof(const IntrinsicInst *I) {
1479 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1480 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1481 }
1482 static bool classof(const Value *V) {
1484 }
1485 LLVM_ABI Value *getStep() const;
1486};
1487
1488/// This represents the llvm.instrprof.increment.step intrinsic.
1490public:
1491 static bool classof(const IntrinsicInst *I) {
1492 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1493 }
1494 static bool classof(const Value *V) {
1496 }
1497};
1498
1499/// This represents the llvm.instrprof.callsite intrinsic.
1500/// It is structurally like the increment or step counters, hence the
1501/// inheritance relationship, albeit somewhat tenuous (it's not 'counting' per
1502/// se)
1504public:
1505 static bool classof(const IntrinsicInst *I) {
1506 return I->getIntrinsicID() == Intrinsic::instrprof_callsite;
1507 }
1508 static bool classof(const Value *V) {
1510 }
1511 // We instrument direct calls (but not to intrinsics), or indirect calls.
1512 static bool canInstrumentCallsite(const CallBase &CB) {
1513 return !CB.isInlineAsm() &&
1514 (CB.isIndirectCall() ||
1516 }
1517 LLVM_ABI Value *getCallee() const;
1518 LLVM_ABI void setCallee(Value *Callee);
1519};
1520
1521/// This represents the llvm.instrprof.timestamp intrinsic.
1523public:
1524 static bool classof(const IntrinsicInst *I) {
1525 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1526 }
1527 static bool classof(const Value *V) {
1529 }
1530};
1531
1532/// This represents the llvm.instrprof.value.profile intrinsic.
1534public:
1535 static bool classof(const IntrinsicInst *I) {
1536 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1537 }
1538 static bool classof(const Value *V) {
1540 }
1541
1543
1546 }
1547
1548 // Returns the value site index.
1550};
1551
1552/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1554public:
1555 static bool classof(const IntrinsicInst *I) {
1557 }
1558 static bool classof(const Value *V) {
1560 }
1561
1562 /// \return The number of bits used for the MCDC bitmaps for the instrumented
1563 /// function.
1567
1568 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1569 /// function.
1570 auto getNumBitmapBytes() const {
1571 return alignTo(getNumBitmapBits()->getZExtValue(), CHAR_BIT) / CHAR_BIT;
1572 }
1573};
1574
1575/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1577public:
1578 static bool classof(const IntrinsicInst *I) {
1579 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1580 }
1581 static bool classof(const Value *V) {
1583 }
1584};
1585
1586/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1588public:
1589 static bool classof(const IntrinsicInst *I) {
1590 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1591 }
1592 static bool classof(const Value *V) {
1594 }
1595
1596 /// \return The index of the TestVector Bitmap upon which this intrinsic
1597 /// acts.
1600 }
1601
1602 /// \return The address of the corresponding condition bitmap containing
1603 /// the index of the TestVector to update within the TestVector Bitmap.
1605};
1606
1608public:
1609 static bool classof(const IntrinsicInst *I) {
1610 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1611 }
1612
1613 static bool classof(const Value *V) {
1615 }
1616
1619 }
1620
1622
1625 }
1626
1628};
1629
1631public:
1632 static bool classof(const IntrinsicInst *I) {
1633 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1634 }
1635
1636 static bool classof(const Value *V) {
1638 }
1639
1641 auto *MV =
1643 return cast<MDNode>(MV->getMetadata());
1644 }
1645
1650};
1651
1652/// Common base class for representing values projected from a statepoint.
1653/// Currently, the only projections available are gc.result and gc.relocate.
1655public:
1656 static bool classof(const IntrinsicInst *I) {
1657 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1658 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1659 }
1660
1661 static bool classof(const Value *V) {
1663 }
1664
1665 /// Return true if this relocate is tied to the invoke statepoint.
1666 /// This includes relocates which are on the unwinding path.
1667 bool isTiedToInvoke() const {
1668 const Value *Token = getArgOperand(0);
1669
1670 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1671 }
1672
1673 /// The statepoint with which this gc.relocate is associated.
1674 LLVM_ABI const Value *getStatepoint() const;
1675};
1676
1677/// Represents calls to the gc.relocate intrinsic.
1679public:
1680 static bool classof(const IntrinsicInst *I) {
1681 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1682 }
1683
1684 static bool classof(const Value *V) {
1686 }
1687
1688 /// The index into the associate statepoint's argument list
1689 /// which contains the base pointer of the pointer whose
1690 /// relocation this gc.relocate describes.
1691 unsigned getBasePtrIndex() const {
1692 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1693 }
1694
1695 /// The index into the associate statepoint's argument list which
1696 /// contains the pointer whose relocation this gc.relocate describes.
1697 unsigned getDerivedPtrIndex() const {
1698 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1699 }
1700
1701 LLVM_ABI Value *getBasePtr() const;
1702 LLVM_ABI Value *getDerivedPtr() const;
1703};
1704
1705/// Represents calls to the gc.result intrinsic.
1707public:
1708 static bool classof(const IntrinsicInst *I) {
1709 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1710 }
1711
1712 static bool classof(const Value *V) {
1714 }
1715};
1716
1717
1718/// This represents the llvm.assume intrinsic.
1720public:
1721 static bool classof(const IntrinsicInst *I) {
1722 return I->getIntrinsicID() == Intrinsic::assume;
1723 }
1724 static bool classof(const Value *V) {
1726 }
1727};
1728
1729/// Check if \p ID corresponds to a convergence control intrinsic.
1730static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1731 switch (IntrinsicID) {
1732 default:
1733 return false;
1734 case Intrinsic::experimental_convergence_anchor:
1735 case Intrinsic::experimental_convergence_entry:
1736 case Intrinsic::experimental_convergence_loop:
1737 return true;
1738 }
1739}
1740
1741/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1743public:
1744 static bool classof(const IntrinsicInst *I) {
1745 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1746 }
1747
1748 static bool classof(const Value *V) {
1750 }
1751
1752 bool isAnchor() const {
1753 return getIntrinsicID() == Intrinsic::experimental_convergence_anchor;
1754 }
1755 bool isEntry() const {
1756 return getIntrinsicID() == Intrinsic::experimental_convergence_entry;
1757 }
1758 bool isLoop() const {
1759 return getIntrinsicID() == Intrinsic::experimental_convergence_loop;
1760 }
1761
1766};
1767
1769public:
1770 static bool classof(const IntrinsicInst *I) {
1771 return I->getIntrinsicID() == Intrinsic::structured_alloca;
1772 }
1773
1774 static bool classof(const Value *V) {
1776 }
1777
1779 return getRetAttr(Attribute::ElementType).getValueAsType();
1780 }
1781};
1782
1784public:
1785 static bool classof(const IntrinsicInst *I) {
1786 return I->getIntrinsicID() == Intrinsic::structured_gep;
1787 }
1788
1789 static bool classof(const Value *V) {
1791 }
1792
1793 static unsigned getPointerOperandIndex() { return 0; }
1794
1798
1800 return getParamAttr(0, Attribute::ElementType).getValueAsType();
1801 }
1802
1803 unsigned getNumIndices() const { return arg_size() - 1; }
1804
1805 Value *getIndexOperand(size_t Index) const {
1806 assert(Index < getNumIndices());
1807 return getOperand(Index + 1);
1808 }
1809
1811 return make_range(op_begin() + 1, op_begin() + 1 + getNumIndices());
1812 }
1813
1815 Type *CurrentType = getBaseType();
1816 for (unsigned I = 0; I < getNumIndices(); I++) {
1817 if (ArrayType *AT = dyn_cast<ArrayType>(CurrentType)) {
1818 CurrentType = AT->getElementType();
1819 } else if (VectorType *VT = dyn_cast<VectorType>(CurrentType)) {
1820 CurrentType = VT->getElementType();
1821 } else if (StructType *ST = dyn_cast<StructType>(CurrentType)) {
1823 CurrentType = ST->getElementType(CI->getZExtValue());
1824 } else {
1825 // FIXME(Keenuts): add testing reaching those places once initial
1826 // implementation has landed.
1827 llvm_unreachable("unimplemented");
1828 }
1829 }
1830
1831 return CurrentType;
1832 }
1833};
1834
1835} // end namespace llvm
1836
1837#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)
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:1081
LLVMContext & getContext() const
Definition Metadata.h:1245
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: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...
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: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: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: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: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