LLVM 22.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 /// Checks if the intrinsic is an annotation.
106 switch (getIntrinsicID()) {
107 default: break;
108 case Intrinsic::assume:
109 case Intrinsic::sideeffect:
110 case Intrinsic::pseudoprobe:
111 case Intrinsic::dbg_assign:
112 case Intrinsic::dbg_declare:
113 case Intrinsic::dbg_value:
114 case Intrinsic::dbg_label:
115 case Intrinsic::invariant_start:
116 case Intrinsic::invariant_end:
117 case Intrinsic::lifetime_start:
118 case Intrinsic::lifetime_end:
119 case Intrinsic::experimental_noalias_scope_decl:
120 case Intrinsic::objectsize:
121 case Intrinsic::ptr_annotation:
122 case Intrinsic::var_annotation:
123 return true;
124 }
125 return false;
126 }
127
128 /// Check if the intrinsic might lower into a regular function call in the
129 /// course of IR transformations
131
132 /// Methods for support type inquiry through isa, cast, and dyn_cast:
133 static bool classof(const CallInst *I) {
134 auto *F = dyn_cast_or_null<Function>(I->getCalledOperand());
135 return F && F->isIntrinsic();
136 }
137 static bool classof(const Value *V) {
138 return isa<CallInst>(V) && classof(cast<CallInst>(V));
139 }
140};
141
142/// Check if \p ID corresponds to a lifetime intrinsic.
144 switch (ID) {
145 case Intrinsic::lifetime_start:
146 case Intrinsic::lifetime_end:
147 return true;
148 default:
149 return false;
150 }
151}
152
153/// This is the common base class for lifetime intrinsics.
155public:
156 /// \name Casting methods
157 /// @{
158 static bool classof(const IntrinsicInst *I) {
159 return isLifetimeIntrinsic(I->getIntrinsicID());
160 }
161 static bool classof(const Value *V) {
163 }
164 /// @}
165};
166
167/// Check if \p ID corresponds to a debug info intrinsic.
169 switch (ID) {
170 case Intrinsic::dbg_declare:
171 case Intrinsic::dbg_value:
172 case Intrinsic::dbg_label:
173 case Intrinsic::dbg_assign:
174 return true;
175 default:
176 return false;
177 }
178}
179
180/// This is the common base class for debug info intrinsics.
182public:
183 /// \name Casting methods
184 /// @{
185 static bool classof(const IntrinsicInst *I) {
186 return isDbgInfoIntrinsic(I->getIntrinsicID());
187 }
188 static bool classof(const Value *V) {
190 }
191 /// @}
192};
193
194// Iterator for ValueAsMetadata that internally uses direct pointer iteration
195// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
196// ValueAsMetadata .
198 : public iterator_facade_base<location_op_iterator,
199 std::bidirectional_iterator_tag, Value *> {
201
202public:
203 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
204 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
205
208 I = R.I;
209 return *this;
210 }
211 bool operator==(const location_op_iterator &RHS) const { return I == RHS.I; }
212 const Value *operator*() const {
216 return VAM->getValue();
217 };
226 I = cast<ValueAsMetadata *>(I) + 1;
227 else
228 I = cast<ValueAsMetadata **>(I) + 1;
229 return *this;
230 }
233 I = cast<ValueAsMetadata *>(I) - 1;
234 else
235 I = cast<ValueAsMetadata **>(I) - 1;
236 return *this;
237 }
238};
239
240/// Lightweight class that wraps the location operand metadata of a debug
241/// intrinsic. The raw location may be a ValueAsMetadata, an empty MDTuple,
242/// or a DIArgList.
244 Metadata *RawLocation = nullptr;
245
246public:
248 explicit RawLocationWrapper(Metadata *RawLocation)
249 : RawLocation(RawLocation) {
250 // Allow ValueAsMetadata, empty MDTuple, DIArgList.
251 assert(RawLocation && "unexpected null RawLocation");
252 assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
253 (isa<MDNode>(RawLocation) &&
254 !cast<MDNode>(RawLocation)->getNumOperands()));
255 }
256 Metadata *getRawLocation() const { return RawLocation; }
257 /// Get the locations corresponding to the variable referenced by the debug
258 /// info intrinsic. Depending on the intrinsic, this could be the
259 /// variable's value or its address.
261 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
262 unsigned getNumVariableLocationOps() const {
263 if (hasArgList())
264 return cast<DIArgList>(getRawLocation())->getArgs().size();
265 return 1;
266 }
267 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
269 // Check for "kill" sentinel values.
270 // Non-variadic: empty metadata.
272 return true;
273 // Variadic: empty DIArgList with empty expression.
274 if (getNumVariableLocationOps() == 0 && !Expression->isComplex())
275 return true;
276 // Variadic and non-variadic: Interpret expressions using undef or poison
277 // values as kills.
278 return any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
279 }
280
281 friend bool operator==(const RawLocationWrapper &A,
282 const RawLocationWrapper &B) {
283 return A.RawLocation == B.RawLocation;
284 }
285 friend bool operator!=(const RawLocationWrapper &A,
286 const RawLocationWrapper &B) {
287 return !(A == B);
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.RawLocation >= B.RawLocation;
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};
306
307/// This is the common base class for debug info intrinsics for variables.
309public:
310 /// Get the locations corresponding to the variable referenced by the debug
311 /// info intrinsic. Depending on the intrinsic, this could be the
312 /// variable's value or its address.
314
315 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
316
317 LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
318 bool AllowEmpty = false);
319 LLVM_ABI void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
320 /// Adding a new location operand will always result in this intrinsic using
321 /// an ArgList, and must always be accompanied by a new expression that uses
322 /// the new operand.
325
327 setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
328 }
329
333
337
338 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
339
340 /// Does this describe the address of a local variable. True for dbg.declare,
341 /// but not dbg.value, which describes its value, or dbg.assign, which
342 /// describes a combination of the variable's value and address.
343 bool isAddressOfVariable() const {
344 return getIntrinsicID() == Intrinsic::dbg_declare;
345 }
346
347 /// Determine if this describes the value of a local variable. It is true for
348 /// dbg.value, but false for dbg.declare, which describes its address, and
349 /// false for dbg.assign, which describes a combination of the variable's
350 /// value and address.
351 bool isValueOfVariable() const {
352 return getIntrinsicID() == Intrinsic::dbg_value;
353 }
354
356 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
357 // this set anymore.
358 SmallPtrSet<Value *, 4> RemovedValues;
359 for (Value *OldValue : location_ops()) {
360 if (!RemovedValues.insert(OldValue).second)
361 continue;
362 Value *Poison = PoisonValue::get(OldValue->getType());
364 }
365 }
366
367 bool isKillLocation() const {
369 }
370
374
378
380 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
381 }
382
386
388 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
389 }
390
392 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
393 }
394
395 /// Use of this should generally be avoided; instead,
396 /// replaceVariableLocationOp and addVariableLocationOps should be used where
397 /// possible to avoid creating invalid state.
398 void setRawLocation(Metadata *Location) {
399 return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
400 }
401
402 /// Get the size (in bits) of the variable, or fragment of the variable that
403 /// is described.
404 LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
405
406 /// Get the FragmentInfo for the variable.
407 std::optional<DIExpression::FragmentInfo> getFragment() const {
408 return getExpression()->getFragmentInfo();
409 }
410
411 /// Get the FragmentInfo for the variable if it exists, otherwise return a
412 /// FragmentInfo that covers the entire variable if the variable size is
413 /// known, otherwise return a zero-sized fragment.
415 DIExpression::FragmentInfo VariableSlice(0, 0);
416 // Get the fragment or variable size, or zero.
417 if (auto Sz = getFragmentSizeInBits())
418 VariableSlice.SizeInBits = *Sz;
419 if (auto Frag = getExpression()->getFragmentInfo())
420 VariableSlice.OffsetInBits = Frag->OffsetInBits;
421 return VariableSlice;
422 }
423
424 /// \name Casting methods
425 /// @{
426 static bool classof(const IntrinsicInst *I) {
427 switch (I->getIntrinsicID()) {
428 case Intrinsic::dbg_declare:
429 case Intrinsic::dbg_value:
430 case Intrinsic::dbg_assign:
431 return true;
432 default:
433 return false;
434 }
435 }
436 static bool classof(const Value *V) {
438 }
439 /// @}
440protected:
441 void setArgOperand(unsigned i, Value *v) {
443 }
444 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
445};
446
447/// This represents the llvm.dbg.declare instruction.
449public:
450 Value *getAddress() const {
452 "dbg.declare must have exactly 1 location operand.");
453 return getVariableLocationOp(0);
454 }
455
456 /// \name Casting methods
457 /// @{
458 static bool classof(const IntrinsicInst *I) {
459 return I->getIntrinsicID() == Intrinsic::dbg_declare;
460 }
461 static bool classof(const Value *V) {
463 }
464 /// @}
465};
466
467/// This represents the llvm.dbg.value instruction.
469public:
470 // The default argument should only be used in ISel, and the default option
471 // should be removed once ISel support for multiple location ops is complete.
472 Value *getValue(unsigned OpIdx = 0) const {
474 }
478
479 /// \name Casting methods
480 /// @{
481 static bool classof(const IntrinsicInst *I) {
482 return I->getIntrinsicID() == Intrinsic::dbg_value ||
483 I->getIntrinsicID() == Intrinsic::dbg_assign;
484 }
485 static bool classof(const Value *V) {
487 }
488 /// @}
489};
490
491/// This represents the llvm.dbg.assign instruction.
493 enum Operands {
494 OpValue,
495 OpVar,
496 OpExpr,
497 OpAssignID,
498 OpAddress,
499 OpAddressExpr,
500 };
501
502public:
503 LLVM_ABI Value *getAddress() const;
505 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
506 }
508 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
509 }
512 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
513 }
518 setArgOperand(OpAddressExpr,
519 MetadataAsValue::get(NewExpr->getContext(), NewExpr));
520 }
522 LLVM_ABI void setAddress(Value *V);
523 /// Kill the address component.
525 /// Check whether this kills the address component. This doesn't take into
526 /// account the position of the intrinsic, therefore a returned value of false
527 /// does not guarentee the address is a valid location for the variable at the
528 /// intrinsic's position in IR.
529 LLVM_ABI bool isKillAddress() const;
530 LLVM_ABI void setValue(Value *V);
531 /// \name Casting methods
532 /// @{
533 static bool classof(const IntrinsicInst *I) {
534 return I->getIntrinsicID() == Intrinsic::dbg_assign;
535 }
536 static bool classof(const Value *V) {
538 }
539 /// @}
540};
541
542/// This represents the llvm.dbg.label instruction.
544public:
546 void setLabel(DILabel *NewLabel) {
548 }
549
551 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
552 }
553
554 /// Methods for support type inquiry through isa, cast, and dyn_cast:
555 /// @{
556 static bool classof(const IntrinsicInst *I) {
557 return I->getIntrinsicID() == Intrinsic::dbg_label;
558 }
559 static bool classof(const Value *V) {
561 }
562 /// @}
563};
564
565/// This is the common base class for vector predication intrinsics.
567public:
568 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
569 /// \p Params. Additionally, the load and gather intrinsics require
570 /// \p ReturnType to be specified.
571 LLVM_ABI static Function *
573 ArrayRef<Value *> Params);
574
575 LLVM_ABI static std::optional<unsigned>
576 getMaskParamPos(Intrinsic::ID IntrinsicID);
577 LLVM_ABI static std::optional<unsigned>
579
580 /// The llvm.vp.* intrinsics for this instruction Opcode
581 LLVM_ABI static Intrinsic::ID getForOpcode(unsigned OC);
582
583 /// The llvm.vp.* intrinsics for this intrinsic ID \p Id. Return \p Id if it
584 /// is already a VP intrinsic.
586
587 // Whether \p ID is a VP intrinsic ID.
589
590 /// \return The mask parameter or nullptr.
591 LLVM_ABI Value *getMaskParam() const;
593
594 /// \return The vector length parameter or nullptr.
597
598 /// \return Whether the vector length param can be ignored.
600
601 /// \return The static element count (vector number of elements) the vector
602 /// length parameter applies to.
604
605 /// \return The alignment of the pointer used by this load/store/gather or
606 /// scatter.
608 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
609
610 /// \return The pointer operand of this load,store, gather or scatter.
612 LLVM_ABI static std::optional<unsigned>
614
615 /// \return The data (payload) operand of this store or scatter.
617 LLVM_ABI static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
618
619 // Methods for support type inquiry through isa, cast, and dyn_cast:
620 static bool classof(const IntrinsicInst *I) {
621 return isVPIntrinsic(I->getIntrinsicID());
622 }
623 static bool classof(const Value *V) {
625 }
626
627 // Equivalent non-predicated opcode
628 std::optional<unsigned> getFunctionalOpcode() const {
630 }
631
632 // Equivalent non-predicated intrinsic ID
633 std::optional<unsigned> getFunctionalIntrinsicID() const {
635 }
636
637 // Equivalent non-predicated constrained ID
638 std::optional<unsigned> getConstrainedIntrinsicID() const {
640 }
641
642 // Equivalent non-predicated opcode
643 LLVM_ABI static std::optional<unsigned>
645
646 // Equivalent non-predicated intrinsic ID
647 LLVM_ABI static std::optional<Intrinsic::ID>
649
650 // Equivalent non-predicated constrained ID
651 LLVM_ABI static std::optional<Intrinsic::ID>
653};
654
655/// This represents vector predication reduction intrinsics.
657public:
659
660 LLVM_ABI unsigned getStartParamPos() const;
661 LLVM_ABI unsigned getVectorParamPos() const;
662
663 LLVM_ABI static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
664 LLVM_ABI static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
665
666 /// Methods for support type inquiry through isa, cast, and dyn_cast:
667 /// @{
668 static bool classof(const IntrinsicInst *I) {
669 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
670 }
671 static bool classof(const Value *V) {
673 }
674 /// @}
675};
676
678public:
679 LLVM_ABI static bool isVPCast(Intrinsic::ID ID);
680
681 /// Methods for support type inquiry through isa, cast, and dyn_cast:
682 /// @{
683 static bool classof(const IntrinsicInst *I) {
684 return VPCastIntrinsic::isVPCast(I->getIntrinsicID());
685 }
686 static bool classof(const Value *V) {
688 }
689 /// @}
690};
691
693public:
694 LLVM_ABI static bool isVPCmp(Intrinsic::ID ID);
695
697
698 /// Methods for support type inquiry through isa, cast, and dyn_cast:
699 /// @{
700 static bool classof(const IntrinsicInst *I) {
701 return VPCmpIntrinsic::isVPCmp(I->getIntrinsicID());
702 }
703 static bool classof(const Value *V) {
705 }
706 /// @}
707};
708
710public:
711 LLVM_ABI static bool isVPBinOp(Intrinsic::ID ID);
712
713 /// Methods for support type inquiry through isa, cast, and dyn_cast:
714 /// @{
715 static bool classof(const IntrinsicInst *I) {
716 return VPBinOpIntrinsic::isVPBinOp(I->getIntrinsicID());
717 }
718 static bool classof(const Value *V) {
720 }
721 /// @}
722};
723
724
725/// This is the common base class for constrained floating point intrinsics.
727public:
728 LLVM_ABI unsigned getNonMetadataArgCount() const;
729 LLVM_ABI std::optional<RoundingMode> getRoundingMode() const;
730 LLVM_ABI std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
731 LLVM_ABI bool isDefaultFPEnvironment() const;
732
733 // Methods for support type inquiry through isa, cast, and dyn_cast:
734 LLVM_ABI static bool classof(const IntrinsicInst *I);
735 static bool classof(const Value *V) {
737 }
738};
739
740/// Constrained floating point compare intrinsics.
742public:
744 bool isSignaling() const {
745 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
746 }
747
748 // Methods for support type inquiry through isa, cast, and dyn_cast:
749 static bool classof(const IntrinsicInst *I) {
750 switch (I->getIntrinsicID()) {
751 case Intrinsic::experimental_constrained_fcmp:
752 case Intrinsic::experimental_constrained_fcmps:
753 return true;
754 default:
755 return false;
756 }
757 }
758 static bool classof(const Value *V) {
760 }
761};
762
763/// This class represents min/max intrinsics.
765public:
766 static bool classof(const IntrinsicInst *I) {
767 switch (I->getIntrinsicID()) {
768 case Intrinsic::umin:
769 case Intrinsic::umax:
770 case Intrinsic::smin:
771 case Intrinsic::smax:
772 return true;
773 default:
774 return false;
775 }
776 }
777 static bool classof(const Value *V) {
779 }
780
781 Value *getLHS() const { return getArgOperand(0); }
782 Value *getRHS() const { return getArgOperand(1); }
783
784 /// Returns the comparison predicate underlying the intrinsic.
786 switch (ID) {
787 case Intrinsic::umin:
789 case Intrinsic::umax:
791 case Intrinsic::smin:
793 case Intrinsic::smax:
795 default:
796 llvm_unreachable("Invalid intrinsic");
797 }
798 }
799
800 /// Returns the comparison predicate underlying the intrinsic.
804
805 /// Whether the intrinsic is signed or unsigned.
806 static bool isSigned(Intrinsic::ID ID) {
808 };
809
810 /// Whether the intrinsic is signed or unsigned.
811 bool isSigned() const { return isSigned(getIntrinsicID()); };
812
813 /// Whether the intrinsic is a smin or umin.
814 static bool isMin(Intrinsic::ID ID) {
815 switch (ID) {
816 case Intrinsic::umin:
817 case Intrinsic::smin:
818 return true;
819 case Intrinsic::umax:
820 case Intrinsic::smax:
821 return false;
822 default:
823 llvm_unreachable("Invalid intrinsic");
824 }
825 }
826
827 /// Whether the intrinsic is a smin or a umin.
828 bool isMin() const { return isMin(getIntrinsicID()); }
829
830 /// Whether the intrinsic is a smax or a umax.
831 bool isMax() const { return !isMin(getIntrinsicID()); }
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.
836 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
837 switch (ID) {
838 case Intrinsic::umin:
839 return APInt::getMinValue(numBits);
840 case Intrinsic::umax:
841 return APInt::getMaxValue(numBits);
842 case Intrinsic::smin:
843 return APInt::getSignedMinValue(numBits);
844 case Intrinsic::smax:
845 return APInt::getSignedMaxValue(numBits);
846 default:
847 llvm_unreachable("Invalid intrinsic");
848 }
849 }
850
851 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
852 /// so there is a certain threshold value, upon reaching which,
853 /// their value can no longer change. Return said threshold.
854 APInt getSaturationPoint(unsigned numBits) const {
855 return getSaturationPoint(getIntrinsicID(), numBits);
856 }
857
858 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
859 /// so there is a certain threshold value, upon reaching which,
860 /// their value can no longer change. Return said threshold.
863 Ty, getSaturationPoint(ID, Ty->getScalarSizeInBits()));
864 }
865
866 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
867 /// so there is a certain threshold value, upon reaching which,
868 /// their value can no longer change. Return said threshold.
871 }
872};
873
874/// This class represents a ucmp/scmp intrinsic
876public:
877 static bool classof(const IntrinsicInst *I) {
878 switch (I->getIntrinsicID()) {
879 case Intrinsic::scmp:
880 case Intrinsic::ucmp:
881 return true;
882 default:
883 return false;
884 }
885 }
886 static bool classof(const Value *V) {
888 }
889
890 Value *getLHS() const { return getArgOperand(0); }
891 Value *getRHS() const { return getArgOperand(1); }
892
893 static bool isSigned(Intrinsic::ID ID) { return ID == Intrinsic::scmp; }
894 bool isSigned() const { return isSigned(getIntrinsicID()); }
895
902
909};
910
911/// This class represents an intrinsic that is based on a binary operation.
912/// This includes op.with.overflow and saturating add/sub intrinsics.
914public:
915 static bool classof(const IntrinsicInst *I) {
916 switch (I->getIntrinsicID()) {
917 case Intrinsic::uadd_with_overflow:
918 case Intrinsic::sadd_with_overflow:
919 case Intrinsic::usub_with_overflow:
920 case Intrinsic::ssub_with_overflow:
921 case Intrinsic::umul_with_overflow:
922 case Intrinsic::smul_with_overflow:
923 case Intrinsic::uadd_sat:
924 case Intrinsic::sadd_sat:
925 case Intrinsic::usub_sat:
926 case Intrinsic::ssub_sat:
927 return true;
928 default:
929 return false;
930 }
931 }
932 static bool classof(const Value *V) {
934 }
935
936 Value *getLHS() const { return getArgOperand(0); }
937 Value *getRHS() const { return getArgOperand(1); }
938
939 /// Returns the binary operation underlying the intrinsic.
941
942 /// Whether the intrinsic is signed or unsigned.
943 LLVM_ABI bool isSigned() const;
944
945 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
946 LLVM_ABI unsigned getNoWrapKind() const;
947};
948
949/// Represents an op.with.overflow intrinsic.
951public:
952 static bool classof(const IntrinsicInst *I) {
953 switch (I->getIntrinsicID()) {
954 case Intrinsic::uadd_with_overflow:
955 case Intrinsic::sadd_with_overflow:
956 case Intrinsic::usub_with_overflow:
957 case Intrinsic::ssub_with_overflow:
958 case Intrinsic::umul_with_overflow:
959 case Intrinsic::smul_with_overflow:
960 return true;
961 default:
962 return false;
963 }
964 }
965 static bool classof(const Value *V) {
967 }
968};
969
970/// Represents a saturating add/sub intrinsic.
972public:
973 static bool classof(const IntrinsicInst *I) {
974 switch (I->getIntrinsicID()) {
975 case Intrinsic::uadd_sat:
976 case Intrinsic::sadd_sat:
977 case Intrinsic::usub_sat:
978 case Intrinsic::ssub_sat:
979 return true;
980 default:
981 return false;
982 }
983 }
984 static bool classof(const Value *V) {
986 }
987};
988
989/// Common base class for all memory intrinsics. Simply provides
990/// common methods.
991/// Written as CRTP to avoid a common base class amongst the
992/// three atomicity hierarchies.
993template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
994private:
995 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
996
997public:
998 Value *getRawDest() const {
999 return const_cast<Value *>(getArgOperand(ARG_DEST));
1000 }
1001 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
1002 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
1003
1004 Value *getLength() const {
1005 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
1006 }
1007 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
1008 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
1009
1010 std::optional<APInt> getLengthInBytes() const {
1012 if (!C)
1013 return std::nullopt;
1014 return C->getValue();
1015 }
1016
1017 /// This is just like getRawDest, but it strips off any cast
1018 /// instructions (including addrspacecast) that feed it, giving the
1019 /// original input. The returned value is guaranteed to be a pointer.
1020 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
1021
1022 unsigned getDestAddressSpace() const {
1023 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
1024 }
1025
1026 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
1027
1028 /// Set the specified arguments of the instruction.
1030 assert(getRawDest()->getType() == Ptr->getType() &&
1031 "setDest called with pointer of wrong type!");
1032 setArgOperand(ARG_DEST, Ptr);
1033 }
1034
1036 removeParamAttr(ARG_DEST, Attribute::Alignment);
1037 if (Alignment)
1038 addParamAttr(ARG_DEST,
1040 }
1041 void setDestAlignment(Align Alignment) {
1042 removeParamAttr(ARG_DEST, Attribute::Alignment);
1043 addParamAttr(ARG_DEST,
1045 }
1046
1047 void setLength(Value *L) {
1048 assert(getLength()->getType() == L->getType() &&
1049 "setLength called with value of wrong type!");
1050 setArgOperand(ARG_LENGTH, L);
1051 }
1052
1054 setLength(ConstantInt::get(getLength()->getType(), L));
1055 }
1056};
1057
1058/// Common base class for all memory transfer intrinsics. Simply provides
1059/// common methods.
1060template <class BaseCL> class MemTransferBase : public BaseCL {
1061private:
1062 enum { ARG_SOURCE = 1 };
1063
1064public:
1065 /// Return the arguments to the instruction.
1067 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
1068 }
1069 const Use &getRawSourceUse() const {
1070 return BaseCL::getArgOperandUse(ARG_SOURCE);
1071 }
1072 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
1073
1074 /// This is just like getRawSource, but it strips off any cast
1075 /// instructions that feed it, giving the original input. The returned
1076 /// value is guaranteed to be a pointer.
1078
1079 unsigned getSourceAddressSpace() const {
1080 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
1081 }
1082
1084 return BaseCL::getParamAlign(ARG_SOURCE);
1085 }
1086
1088 assert(getRawSource()->getType() == Ptr->getType() &&
1089 "setSource called with pointer of wrong type!");
1090 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1091 }
1092
1094 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1095 if (Alignment)
1096 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1097 BaseCL::getContext(), *Alignment));
1098 }
1099
1100 void setSourceAlignment(Align Alignment) {
1101 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1102 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1103 BaseCL::getContext(), Alignment));
1104 }
1105};
1106
1107/// Common base class for all memset intrinsics. Simply provides
1108/// common methods.
1109template <class BaseCL> class MemSetBase : public BaseCL {
1110private:
1111 enum { ARG_VALUE = 1 };
1112
1113public:
1114 Value *getValue() const {
1115 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1116 }
1117 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1118 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1119
1120 void setValue(Value *Val) {
1121 assert(getValue()->getType() == Val->getType() &&
1122 "setValue called with value of wrong type!");
1123 BaseCL::setArgOperand(ARG_VALUE, Val);
1124 }
1125};
1126
1127/// This is the common base class for memset/memcpy/memmove.
1128class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1129private:
1130 enum { ARG_VOLATILE = 3 };
1131
1132public:
1134 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1135 }
1136
1137 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1138
1139 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1140
1141 bool isForceInlined() const {
1142 switch (getIntrinsicID()) {
1143 case Intrinsic::memset_inline:
1144 case Intrinsic::memcpy_inline:
1145 return true;
1146 default:
1147 return false;
1148 }
1149 }
1150
1151 // Methods for support type inquiry through isa, cast, and dyn_cast:
1152 static bool classof(const IntrinsicInst *I) {
1153 switch (I->getIntrinsicID()) {
1154 case Intrinsic::memcpy:
1155 case Intrinsic::memmove:
1156 case Intrinsic::memset:
1157 case Intrinsic::memset_inline:
1158 case Intrinsic::memcpy_inline:
1159 return true;
1160 default:
1161 return false;
1162 }
1163 }
1164 static bool classof(const Value *V) {
1166 }
1167};
1168
1169/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1170class MemSetInst : public MemSetBase<MemIntrinsic> {
1171public:
1172 // Methods for support type inquiry through isa, cast, and dyn_cast:
1173 static bool classof(const IntrinsicInst *I) {
1174 switch (I->getIntrinsicID()) {
1175 case Intrinsic::memset:
1176 case Intrinsic::memset_inline:
1177 return true;
1178 default:
1179 return false;
1180 }
1181 }
1182 static bool classof(const Value *V) {
1184 }
1185};
1186
1187/// This class wraps the llvm.experimental.memset.pattern intrinsic.
1188/// Note that despite the inheritance, this is not part of the
1189/// MemIntrinsic hierachy in terms of isa/cast.
1190class MemSetPatternInst : public MemSetBase<MemIntrinsic> {
1191private:
1192 enum { ARG_VOLATILE = 3 };
1193
1194public:
1196 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1197 }
1198
1199 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1200
1201 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1202
1203 // Methods for support type inquiry through isa, cast, and dyn_cast:
1204 static bool classof(const IntrinsicInst *I) {
1205 return I->getIntrinsicID() == Intrinsic::experimental_memset_pattern;
1206 }
1207 static bool classof(const Value *V) {
1209 }
1210};
1211
1212/// This class wraps the llvm.memcpy/memmove intrinsics.
1213class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1214public:
1215 // Methods for support type inquiry through isa, cast, and dyn_cast:
1216 static bool classof(const IntrinsicInst *I) {
1217 switch (I->getIntrinsicID()) {
1218 case Intrinsic::memcpy:
1219 case Intrinsic::memmove:
1220 case Intrinsic::memcpy_inline:
1221 return true;
1222 default:
1223 return false;
1224 }
1225 }
1226 static bool classof(const Value *V) {
1228 }
1229};
1230
1231/// This class wraps the llvm.memcpy intrinsic.
1233public:
1234 // Methods for support type inquiry through isa, cast, and dyn_cast:
1235 static bool classof(const IntrinsicInst *I) {
1236 return I->getIntrinsicID() == Intrinsic::memcpy ||
1237 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1238 }
1239 static bool classof(const Value *V) {
1241 }
1242};
1243
1244/// This class wraps the llvm.memmove intrinsic.
1246public:
1247 // Methods for support type inquiry through isa, cast, and dyn_cast:
1248 static bool classof(const IntrinsicInst *I) {
1249 return I->getIntrinsicID() == Intrinsic::memmove;
1250 }
1251 static bool classof(const Value *V) {
1253 }
1254};
1255
1256// The common base class for any memset/memmove/memcpy intrinsics;
1257// whether they be atomic or non-atomic.
1258// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1259// and llvm.memset/memcpy/memmove
1260class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1261private:
1262 enum { ARG_ELEMENTSIZE = 3 };
1263
1264public:
1265 bool isVolatile() const {
1266 // Only the non-atomic intrinsics can be volatile
1267 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1268 return MI->isVolatile();
1269 return false;
1270 }
1271
1272 bool isAtomic() const {
1273 switch (getIntrinsicID()) {
1274 case Intrinsic::memcpy_element_unordered_atomic:
1275 case Intrinsic::memmove_element_unordered_atomic:
1276 case Intrinsic::memset_element_unordered_atomic:
1277 return true;
1278 default:
1279 return false;
1280 }
1281 }
1282
1283 static bool classof(const IntrinsicInst *I) {
1284 switch (I->getIntrinsicID()) {
1285 case Intrinsic::memcpy:
1286 case Intrinsic::memcpy_inline:
1287 case Intrinsic::memmove:
1288 case Intrinsic::memset:
1289 case Intrinsic::memset_inline:
1290 case Intrinsic::memcpy_element_unordered_atomic:
1291 case Intrinsic::memmove_element_unordered_atomic:
1292 case Intrinsic::memset_element_unordered_atomic:
1293 return true;
1294 default:
1295 return false;
1296 }
1297 }
1298 static bool classof(const Value *V) {
1300 }
1301
1303 assert(isAtomic());
1304 return getArgOperand(ARG_ELEMENTSIZE);
1305 }
1306
1308 assert(isAtomic());
1309 return cast<ConstantInt>(getRawElementSizeInBytes())->getZExtValue();
1310 }
1311};
1312
1313/// This class represents any memset intrinsic
1314// i.e. llvm.element.unordered.atomic.memset
1315// and llvm.memset
1316class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1317public:
1318 static bool classof(const IntrinsicInst *I) {
1319 switch (I->getIntrinsicID()) {
1320 case Intrinsic::memset:
1321 case Intrinsic::memset_inline:
1322 case Intrinsic::memset_element_unordered_atomic:
1323 return true;
1324 default:
1325 return false;
1326 }
1327 }
1328 static bool classof(const Value *V) {
1330 }
1331};
1332
1333// This class wraps any memcpy/memmove intrinsics
1334// i.e. llvm.element.unordered.atomic.memcpy/memmove
1335// and llvm.memcpy/memmove
1336class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1337public:
1338 static bool classof(const IntrinsicInst *I) {
1339 switch (I->getIntrinsicID()) {
1340 case Intrinsic::memcpy:
1341 case Intrinsic::memcpy_inline:
1342 case Intrinsic::memmove:
1343 case Intrinsic::memcpy_element_unordered_atomic:
1344 case Intrinsic::memmove_element_unordered_atomic:
1345 return true;
1346 default:
1347 return false;
1348 }
1349 }
1350 static bool classof(const Value *V) {
1352 }
1353};
1354
1355/// This class represents any memcpy intrinsic
1356/// i.e. llvm.element.unordered.atomic.memcpy
1357/// and llvm.memcpy
1359public:
1360 static bool classof(const IntrinsicInst *I) {
1361 switch (I->getIntrinsicID()) {
1362 case Intrinsic::memcpy:
1363 case Intrinsic::memcpy_inline:
1364 case Intrinsic::memcpy_element_unordered_atomic:
1365 return true;
1366 default:
1367 return false;
1368 }
1369 }
1370 static bool classof(const Value *V) {
1372 }
1373};
1374
1375/// This class represents any memmove intrinsic
1376/// i.e. llvm.element.unordered.atomic.memmove
1377/// and llvm.memmove
1379public:
1380 static bool classof(const IntrinsicInst *I) {
1381 switch (I->getIntrinsicID()) {
1382 case Intrinsic::memmove:
1383 case Intrinsic::memmove_element_unordered_atomic:
1384 return true;
1385 default:
1386 return false;
1387 }
1388 }
1389 static bool classof(const Value *V) {
1391 }
1392};
1393
1394/// This represents the llvm.va_start intrinsic.
1396public:
1397 static bool classof(const IntrinsicInst *I) {
1398 return I->getIntrinsicID() == Intrinsic::vastart;
1399 }
1400 static bool classof(const Value *V) {
1402 }
1403
1404 Value *getArgList() const { return getArgOperand(0); }
1405};
1406
1407/// This represents the llvm.va_end intrinsic.
1408class VAEndInst : public IntrinsicInst {
1409public:
1410 static bool classof(const IntrinsicInst *I) {
1411 return I->getIntrinsicID() == Intrinsic::vaend;
1412 }
1413 static bool classof(const Value *V) {
1415 }
1416
1417 Value *getArgList() const { return getArgOperand(0); }
1418};
1419
1420/// This represents the llvm.va_copy intrinsic.
1422public:
1423 static bool classof(const IntrinsicInst *I) {
1424 return I->getIntrinsicID() == Intrinsic::vacopy;
1425 }
1426 static bool classof(const Value *V) {
1428 }
1429
1430 Value *getDest() const { return getArgOperand(0); }
1431 Value *getSrc() const { return getArgOperand(1); }
1432};
1433
1434/// A base class for all instrprof intrinsics.
1436protected:
1437 static bool isCounterBase(const IntrinsicInst &I) {
1438 switch (I.getIntrinsicID()) {
1439 case Intrinsic::instrprof_cover:
1440 case Intrinsic::instrprof_increment:
1441 case Intrinsic::instrprof_increment_step:
1442 case Intrinsic::instrprof_callsite:
1443 case Intrinsic::instrprof_timestamp:
1444 case Intrinsic::instrprof_value_profile:
1445 return true;
1446 }
1447 return false;
1448 }
1449 static bool isMCDCBitmapBase(const IntrinsicInst &I) {
1450 switch (I.getIntrinsicID()) {
1451 case Intrinsic::instrprof_mcdc_parameters:
1452 case Intrinsic::instrprof_mcdc_tvbitmap_update:
1453 return true;
1454 }
1455 return false;
1456 }
1457
1458public:
1459 static bool classof(const Value *V) {
1460 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1461 return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr);
1462 return false;
1463 }
1464
1465 // The name of the instrumented function, assuming it is a global variable.
1468 }
1469
1470 // The "name" operand of the profile instrumentation instruction - this is the
1471 // operand that can be used to relate the instruction to the function it
1472 // belonged to at instrumentation time.
1474
1476
1477 // The hash of the CFG for the instrumented function.
1479};
1480
1481/// A base class for all instrprof counter intrinsics.
1483public:
1484 static bool classof(const Value *V) {
1485 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1486 return InstrProfInstBase::isCounterBase(*Instr);
1487 return false;
1488 }
1489
1490 // The number of counters for the instrumented function.
1492 // The index of the counter that this instruction acts on.
1493 LLVM_ABI ConstantInt *getIndex() const;
1494 LLVM_ABI void setIndex(uint32_t Idx);
1495};
1496
1497/// This represents the llvm.instrprof.cover intrinsic.
1499public:
1500 static bool classof(const IntrinsicInst *I) {
1501 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1502 }
1503 static bool classof(const Value *V) {
1505 }
1506};
1507
1508/// This represents the llvm.instrprof.increment intrinsic.
1510public:
1511 static bool classof(const IntrinsicInst *I) {
1512 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1513 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1514 }
1515 static bool classof(const Value *V) {
1517 }
1518 LLVM_ABI Value *getStep() const;
1519};
1520
1521/// This represents the llvm.instrprof.increment.step intrinsic.
1523public:
1524 static bool classof(const IntrinsicInst *I) {
1525 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1526 }
1527 static bool classof(const Value *V) {
1529 }
1530};
1531
1532/// This represents the llvm.instrprof.callsite intrinsic.
1533/// It is structurally like the increment or step counters, hence the
1534/// inheritance relationship, albeit somewhat tenuous (it's not 'counting' per
1535/// se)
1537public:
1538 static bool classof(const IntrinsicInst *I) {
1539 return I->getIntrinsicID() == Intrinsic::instrprof_callsite;
1540 }
1541 static bool classof(const Value *V) {
1543 }
1544 // We instrument direct calls (but not to intrinsics), or indirect calls.
1545 static bool canInstrumentCallsite(const CallBase &CB) {
1546 return !CB.isInlineAsm() &&
1547 (CB.isIndirectCall() ||
1549 }
1550 LLVM_ABI Value *getCallee() const;
1551 LLVM_ABI void setCallee(Value *Callee);
1552};
1553
1554/// This represents the llvm.instrprof.timestamp intrinsic.
1556public:
1557 static bool classof(const IntrinsicInst *I) {
1558 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1559 }
1560 static bool classof(const Value *V) {
1562 }
1563};
1564
1565/// This represents the llvm.instrprof.value.profile intrinsic.
1567public:
1568 static bool classof(const IntrinsicInst *I) {
1569 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1570 }
1571 static bool classof(const Value *V) {
1573 }
1574
1576
1579 }
1580
1581 // Returns the value site index.
1583};
1584
1585/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1587public:
1588 static bool classof(const IntrinsicInst *I) {
1590 }
1591 static bool classof(const Value *V) {
1593 }
1594
1595 /// \return The number of bits used for the MCDC bitmaps for the instrumented
1596 /// function.
1600
1601 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1602 /// function.
1603 auto getNumBitmapBytes() const {
1604 return alignTo(getNumBitmapBits()->getZExtValue(), CHAR_BIT) / CHAR_BIT;
1605 }
1606};
1607
1608/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1610public:
1611 static bool classof(const IntrinsicInst *I) {
1612 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1613 }
1614 static bool classof(const Value *V) {
1616 }
1617};
1618
1619/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1621public:
1622 static bool classof(const IntrinsicInst *I) {
1623 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1624 }
1625 static bool classof(const Value *V) {
1627 }
1628
1629 /// \return The index of the TestVector Bitmap upon which this intrinsic
1630 /// acts.
1633 }
1634
1635 /// \return The address of the corresponding condition bitmap containing
1636 /// the index of the TestVector to update within the TestVector Bitmap.
1638};
1639
1641public:
1642 static bool classof(const IntrinsicInst *I) {
1643 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1644 }
1645
1646 static bool classof(const Value *V) {
1648 }
1649
1652 }
1653
1655
1658 }
1659
1661};
1662
1664public:
1665 static bool classof(const IntrinsicInst *I) {
1666 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1667 }
1668
1669 static bool classof(const Value *V) {
1671 }
1672
1674 auto *MV =
1676 return cast<MDNode>(MV->getMetadata());
1677 }
1678
1683};
1684
1685/// Common base class for representing values projected from a statepoint.
1686/// Currently, the only projections available are gc.result and gc.relocate.
1688public:
1689 static bool classof(const IntrinsicInst *I) {
1690 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1691 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1692 }
1693
1694 static bool classof(const Value *V) {
1696 }
1697
1698 /// Return true if this relocate is tied to the invoke statepoint.
1699 /// This includes relocates which are on the unwinding path.
1700 bool isTiedToInvoke() const {
1701 const Value *Token = getArgOperand(0);
1702
1703 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1704 }
1705
1706 /// The statepoint with which this gc.relocate is associated.
1707 LLVM_ABI const Value *getStatepoint() const;
1708};
1709
1710/// Represents calls to the gc.relocate intrinsic.
1712public:
1713 static bool classof(const IntrinsicInst *I) {
1714 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1715 }
1716
1717 static bool classof(const Value *V) {
1719 }
1720
1721 /// The index into the associate statepoint's argument list
1722 /// which contains the base pointer of the pointer whose
1723 /// relocation this gc.relocate describes.
1724 unsigned getBasePtrIndex() const {
1725 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1726 }
1727
1728 /// The index into the associate statepoint's argument list which
1729 /// contains the pointer whose relocation this gc.relocate describes.
1730 unsigned getDerivedPtrIndex() const {
1731 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1732 }
1733
1734 LLVM_ABI Value *getBasePtr() const;
1735 LLVM_ABI Value *getDerivedPtr() const;
1736};
1737
1738/// Represents calls to the gc.result intrinsic.
1740public:
1741 static bool classof(const IntrinsicInst *I) {
1742 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1743 }
1744
1745 static bool classof(const Value *V) {
1747 }
1748};
1749
1750
1751/// This represents the llvm.assume intrinsic.
1753public:
1754 static bool classof(const IntrinsicInst *I) {
1755 return I->getIntrinsicID() == Intrinsic::assume;
1756 }
1757 static bool classof(const Value *V) {
1759 }
1760};
1761
1762/// Check if \p ID corresponds to a convergence control intrinsic.
1763static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1764 switch (IntrinsicID) {
1765 default:
1766 return false;
1767 case Intrinsic::experimental_convergence_anchor:
1768 case Intrinsic::experimental_convergence_entry:
1769 case Intrinsic::experimental_convergence_loop:
1770 return true;
1771 }
1772}
1773
1774/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1776public:
1777 static bool classof(const IntrinsicInst *I) {
1778 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1779 }
1780
1781 static bool classof(const Value *V) {
1783 }
1784
1785 bool isAnchor() const {
1786 return getIntrinsicID() == Intrinsic::experimental_convergence_anchor;
1787 }
1788 bool isEntry() const {
1789 return getIntrinsicID() == Intrinsic::experimental_convergence_entry;
1790 }
1791 bool isLoop() const {
1792 return getIntrinsicID() == Intrinsic::experimental_convergence_loop;
1793 }
1794
1799};
1800
1801} // end namespace llvm
1802
1803#endif // LLVM_IR_INTRINSICINST_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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:213
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:55
#define I(x, y, z)
Definition MD5.cpp:58
MachineInstr unsigned OpIdx
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:206
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
Definition APInt.h:209
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
Definition APInt.h:216
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Definition APInt.h:219
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)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
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 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.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
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...
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:678
@ ICMP_SLT
signed less than
Definition InstrTypes.h:707
@ ICMP_UGT
unsigned greater than
Definition InstrTypes.h:701
@ ICMP_SGT
signed greater than
Definition InstrTypes.h:705
@ ICMP_ULT
unsigned less than
Definition InstrTypes.h:703
bool isSigned() const
Definition InstrTypes.h:932
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:214
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.
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:1078
LLVMContext & getContext() const
Definition Metadata.h:1242
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:104
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
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.
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 bit of the poin...
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.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
void setOperand(unsigned i, Value *Val)
Definition User.h:237
Value * getOperand(unsigned i) const
Definition User.h:232
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
static LLVM_ABI bool isVPBinOp(Intrinsic::ID ID)
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
static LLVM_ABI bool isVPCast(Intrinsic::ID ID)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
static LLVM_ABI bool isVPCmp(Intrinsic::ID ID)
LLVM_ABI CmpInst::Predicate getPredicate() 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 Intrinsic::ID getForOpcode(unsigned OC)
The llvm.vp.* intrinsics for this instruction Opcode.
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
static LLVM_ABI Intrinsic::ID getForIntrinsic(Intrinsic::ID Id)
The llvm.vp.
LLVM_ABI Value * getMemoryPointerParam() const
std::optional< unsigned > getConstrainedIntrinsicID() const
LLVM_ABI MaybeAlign getPointerAlignment() const
LLVM_ABI Value * getMaskParam() const
LLVM_ABI ElementCount getStaticVectorLength() const
static LLVM_ABI std::optional< Intrinsic::ID > getConstrainedIntrinsicIDForVP(Intrinsic::ID ID)
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:458
Value * getValue() const
Definition Metadata.h:498
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition Value.cpp:701
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.cpp:1099
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
static const int NoAliasScopeDeclScopeArg
Definition Intrinsics.h:39
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:644
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:754
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:1712
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.
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:548
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:144
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:560
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