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