LLVM 23.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 /// Returns the identity value for this min/max intrinsic, such
840 /// that minmax(X, Identity) == X.
841 static APInt getIdentity(Intrinsic::ID ID, unsigned NumBits) {
842 switch (ID) {
843 case Intrinsic::umin:
844 return APInt::getMaxValue(NumBits);
845 case Intrinsic::umax:
846 return APInt::getMinValue(NumBits);
847 case Intrinsic::smin:
848 return APInt::getSignedMaxValue(NumBits);
849 case Intrinsic::smax:
850 return APInt::getSignedMinValue(NumBits);
851 default:
852 llvm_unreachable("Invalid intrinsic");
853 }
854 }
855
856 /// Returns the identity value for this min/max intrinsic, such
857 /// that minmax(X, Identity) == X.
861
862 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
863 /// so there is a certain threshold value, upon reaching which,
864 /// their value can no longer change. Return said threshold.
865 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
866 switch (ID) {
867 case Intrinsic::umin:
868 return APInt::getMinValue(numBits);
869 case Intrinsic::umax:
870 return APInt::getMaxValue(numBits);
871 case Intrinsic::smin:
872 return APInt::getSignedMinValue(numBits);
873 case Intrinsic::smax:
874 return APInt::getSignedMaxValue(numBits);
875 default:
876 llvm_unreachable("Invalid intrinsic");
877 }
878 }
879
880 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
881 /// so there is a certain threshold value, upon reaching which,
882 /// their value can no longer change. Return said threshold.
883 APInt getSaturationPoint(unsigned numBits) const {
884 return getSaturationPoint(getIntrinsicID(), numBits);
885 }
886
887 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
888 /// so there is a certain threshold value, upon reaching which,
889 /// their value can no longer change. Return said threshold.
892 Ty, getSaturationPoint(ID, Ty->getScalarSizeInBits()));
893 }
894
895 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
896 /// so there is a certain threshold value, upon reaching which,
897 /// their value can no longer change. Return said threshold.
900 }
901};
902
903/// This class represents a ucmp/scmp intrinsic
905public:
906 static bool classof(const IntrinsicInst *I) {
907 switch (I->getIntrinsicID()) {
908 case Intrinsic::scmp:
909 case Intrinsic::ucmp:
910 return true;
911 default:
912 return false;
913 }
914 }
915 static bool classof(const Value *V) {
917 }
918
919 Value *getLHS() const { return getArgOperand(0); }
920 Value *getRHS() const { return getArgOperand(1); }
921
922 static bool isSigned(Intrinsic::ID ID) { return ID == Intrinsic::scmp; }
923 bool isSigned() const { return isSigned(getIntrinsicID()); }
924
931
938};
939
940/// This class represents an intrinsic that is based on a binary operation.
941/// This includes op.with.overflow and saturating add/sub intrinsics.
943public:
944 static bool classof(const IntrinsicInst *I) {
945 switch (I->getIntrinsicID()) {
946 case Intrinsic::uadd_with_overflow:
947 case Intrinsic::sadd_with_overflow:
948 case Intrinsic::usub_with_overflow:
949 case Intrinsic::ssub_with_overflow:
950 case Intrinsic::umul_with_overflow:
951 case Intrinsic::smul_with_overflow:
952 case Intrinsic::uadd_sat:
953 case Intrinsic::sadd_sat:
954 case Intrinsic::usub_sat:
955 case Intrinsic::ssub_sat:
956 return true;
957 default:
958 return false;
959 }
960 }
961 static bool classof(const Value *V) {
963 }
964
965 Value *getLHS() const { return getArgOperand(0); }
966 Value *getRHS() const { return getArgOperand(1); }
967
968 /// Returns the binary operation underlying the intrinsic.
970
971 /// Whether the intrinsic is signed or unsigned.
972 LLVM_ABI bool isSigned() const;
973
974 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
975 LLVM_ABI unsigned getNoWrapKind() const;
976};
977
978/// Represents an op.with.overflow intrinsic.
980public:
981 static bool classof(const IntrinsicInst *I) {
982 switch (I->getIntrinsicID()) {
983 case Intrinsic::uadd_with_overflow:
984 case Intrinsic::sadd_with_overflow:
985 case Intrinsic::usub_with_overflow:
986 case Intrinsic::ssub_with_overflow:
987 case Intrinsic::umul_with_overflow:
988 case Intrinsic::smul_with_overflow:
989 return true;
990 default:
991 return false;
992 }
993 }
994 static bool classof(const Value *V) {
996 }
997};
998
999/// Represents a saturating add/sub intrinsic.
1001public:
1002 static bool classof(const IntrinsicInst *I) {
1003 switch (I->getIntrinsicID()) {
1004 case Intrinsic::uadd_sat:
1005 case Intrinsic::sadd_sat:
1006 case Intrinsic::usub_sat:
1007 case Intrinsic::ssub_sat:
1008 return true;
1009 default:
1010 return false;
1011 }
1012 }
1013 static bool classof(const Value *V) {
1015 }
1016};
1017
1018/// Common base class for all memory intrinsics. Simply provides
1019/// common methods.
1020/// Written as CRTP to avoid a common base class amongst the
1021/// three atomicity hierarchies.
1022template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
1023private:
1024 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
1025
1026public:
1028 return const_cast<Value *>(getArgOperand(ARG_DEST));
1029 }
1030 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
1031 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
1032
1033 Value *getLength() const {
1034 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
1035 }
1036 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
1037 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
1038
1039 std::optional<APInt> getLengthInBytes() const {
1041 if (!C)
1042 return std::nullopt;
1043 return C->getValue();
1044 }
1045
1046 /// This is just like getRawDest, but it strips off any cast
1047 /// instructions (including addrspacecast) that feed it, giving the
1048 /// original input. The returned value is guaranteed to be a pointer.
1049 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
1050
1051 unsigned getDestAddressSpace() const {
1052 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
1053 }
1054
1055 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
1056
1057 /// Set the specified arguments of the instruction.
1058 void setDest(Value *Ptr) {
1059 assert(getRawDest()->getType() == Ptr->getType() &&
1060 "setDest called with pointer of wrong type!");
1061 setArgOperand(ARG_DEST, Ptr);
1062 }
1063
1065 removeParamAttr(ARG_DEST, Attribute::Alignment);
1066 if (Alignment)
1067 addParamAttr(ARG_DEST,
1069 }
1070 void setDestAlignment(Align Alignment) {
1071 removeParamAttr(ARG_DEST, Attribute::Alignment);
1072 addParamAttr(ARG_DEST,
1074 }
1075
1076 void setLength(Value *L) {
1077 assert(getLength()->getType() == L->getType() &&
1078 "setLength called with value of wrong type!");
1079 setArgOperand(ARG_LENGTH, L);
1080 }
1081
1083 setLength(ConstantInt::get(getLength()->getType(), L));
1084 }
1085};
1086
1087/// Common base class for all memory transfer intrinsics. Simply provides
1088/// common methods.
1089template <class BaseCL> class MemTransferBase : public BaseCL {
1090private:
1091 enum { ARG_SOURCE = 1 };
1092
1093public:
1094 /// Return the arguments to the instruction.
1096 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
1097 }
1098 const Use &getRawSourceUse() const {
1099 return BaseCL::getArgOperandUse(ARG_SOURCE);
1100 }
1101 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
1102
1103 /// This is just like getRawSource, but it strips off any cast
1104 /// instructions that feed it, giving the original input. The returned
1105 /// value is guaranteed to be a pointer.
1107
1108 unsigned getSourceAddressSpace() const {
1109 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
1110 }
1111
1113 return BaseCL::getParamAlign(ARG_SOURCE);
1114 }
1115
1116 void setSource(Value *Ptr) {
1117 assert(getRawSource()->getType() == Ptr->getType() &&
1118 "setSource called with pointer of wrong type!");
1119 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1120 }
1121
1123 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1124 if (Alignment)
1125 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1126 BaseCL::getContext(), *Alignment));
1127 }
1128
1129 void setSourceAlignment(Align Alignment) {
1130 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1131 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1132 BaseCL::getContext(), Alignment));
1133 }
1134};
1135
1136/// Common base class for all memset intrinsics. Simply provides
1137/// common methods.
1138template <class BaseCL> class MemSetBase : public BaseCL {
1139private:
1140 enum { ARG_VALUE = 1 };
1141
1142public:
1143 Value *getValue() const {
1144 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1145 }
1146 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1147 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1148
1149 void setValue(Value *Val) {
1150 assert(getValue()->getType() == Val->getType() &&
1151 "setValue called with value of wrong type!");
1152 BaseCL::setArgOperand(ARG_VALUE, Val);
1153 }
1154};
1155
1156/// This is the common base class for memset/memcpy/memmove.
1157class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1158private:
1159 enum { ARG_VOLATILE = 3 };
1160
1161public:
1163 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1164 }
1165
1166 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1167
1168 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1169
1170 bool isForceInlined() const {
1171 switch (getIntrinsicID()) {
1172 case Intrinsic::memset_inline:
1173 case Intrinsic::memcpy_inline:
1174 return true;
1175 default:
1176 return false;
1177 }
1178 }
1179
1180 // Methods for support type inquiry through isa, cast, and dyn_cast:
1181 static bool classof(const IntrinsicInst *I) {
1182 switch (I->getIntrinsicID()) {
1183 case Intrinsic::memcpy:
1184 case Intrinsic::memmove:
1185 case Intrinsic::memset:
1186 case Intrinsic::memset_inline:
1187 case Intrinsic::memcpy_inline:
1188 return true;
1189 default:
1190 return false;
1191 }
1192 }
1193 static bool classof(const Value *V) {
1195 }
1196};
1197
1198/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1199class MemSetInst : public MemSetBase<MemIntrinsic> {
1200public:
1201 // Methods for support type inquiry through isa, cast, and dyn_cast:
1202 static bool classof(const IntrinsicInst *I) {
1203 switch (I->getIntrinsicID()) {
1204 case Intrinsic::memset:
1205 case Intrinsic::memset_inline:
1206 return true;
1207 default:
1208 return false;
1209 }
1210 }
1211 static bool classof(const Value *V) {
1213 }
1214};
1215
1216/// This class wraps the llvm.experimental.memset.pattern intrinsic.
1217/// Note that despite the inheritance, this is not part of the
1218/// MemIntrinsic hierachy in terms of isa/cast.
1219class MemSetPatternInst : public MemSetBase<MemIntrinsic> {
1220private:
1221 enum { ARG_VOLATILE = 3 };
1222
1223public:
1225 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1226 }
1227
1228 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1229
1230 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1231
1232 // Methods for support type inquiry through isa, cast, and dyn_cast:
1233 static bool classof(const IntrinsicInst *I) {
1234 return I->getIntrinsicID() == Intrinsic::experimental_memset_pattern;
1235 }
1236 static bool classof(const Value *V) {
1238 }
1239};
1240
1241/// This class wraps the llvm.memcpy/memmove intrinsics.
1242class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1243public:
1244 // Methods for support type inquiry through isa, cast, and dyn_cast:
1245 static bool classof(const IntrinsicInst *I) {
1246 switch (I->getIntrinsicID()) {
1247 case Intrinsic::memcpy:
1248 case Intrinsic::memmove:
1249 case Intrinsic::memcpy_inline:
1250 return true;
1251 default:
1252 return false;
1253 }
1254 }
1255 static bool classof(const Value *V) {
1257 }
1258};
1259
1260/// This class wraps the llvm.memcpy intrinsic.
1262public:
1263 // Methods for support type inquiry through isa, cast, and dyn_cast:
1264 static bool classof(const IntrinsicInst *I) {
1265 return I->getIntrinsicID() == Intrinsic::memcpy ||
1266 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1267 }
1268 static bool classof(const Value *V) {
1270 }
1271};
1272
1273/// This class wraps the llvm.memmove intrinsic.
1275public:
1276 // Methods for support type inquiry through isa, cast, and dyn_cast:
1277 static bool classof(const IntrinsicInst *I) {
1278 return I->getIntrinsicID() == Intrinsic::memmove;
1279 }
1280 static bool classof(const Value *V) {
1282 }
1283};
1284
1285// The common base class for any memset/memmove/memcpy intrinsics;
1286// whether they be atomic or non-atomic.
1287// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1288// and llvm.memset/memcpy/memmove
1289class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1290private:
1291 enum { ARG_ELEMENTSIZE = 3 };
1292
1293public:
1294 bool isVolatile() const {
1295 // Only the non-atomic intrinsics can be volatile
1296 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1297 return MI->isVolatile();
1298 return false;
1299 }
1300
1301 bool isAtomic() const {
1302 switch (getIntrinsicID()) {
1303 case Intrinsic::memcpy_element_unordered_atomic:
1304 case Intrinsic::memmove_element_unordered_atomic:
1305 case Intrinsic::memset_element_unordered_atomic:
1306 return true;
1307 default:
1308 return false;
1309 }
1310 }
1311
1312 static bool classof(const IntrinsicInst *I) {
1313 switch (I->getIntrinsicID()) {
1314 case Intrinsic::memcpy:
1315 case Intrinsic::memcpy_inline:
1316 case Intrinsic::memmove:
1317 case Intrinsic::memset:
1318 case Intrinsic::memset_inline:
1319 case Intrinsic::memcpy_element_unordered_atomic:
1320 case Intrinsic::memmove_element_unordered_atomic:
1321 case Intrinsic::memset_element_unordered_atomic:
1322 return true;
1323 default:
1324 return false;
1325 }
1326 }
1327 static bool classof(const Value *V) {
1329 }
1330
1332 assert(isAtomic());
1333 return getArgOperand(ARG_ELEMENTSIZE);
1334 }
1335
1337 assert(isAtomic());
1338 return cast<ConstantInt>(getRawElementSizeInBytes())->getZExtValue();
1339 }
1340};
1341
1342/// This class represents any memset intrinsic
1343// i.e. llvm.element.unordered.atomic.memset
1344// and llvm.memset
1345class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1346public:
1347 static bool classof(const IntrinsicInst *I) {
1348 switch (I->getIntrinsicID()) {
1349 case Intrinsic::memset:
1350 case Intrinsic::memset_inline:
1351 case Intrinsic::memset_element_unordered_atomic:
1352 return true;
1353 default:
1354 return false;
1355 }
1356 }
1357 static bool classof(const Value *V) {
1359 }
1360};
1361
1362// This class wraps any memcpy/memmove intrinsics
1363// i.e. llvm.element.unordered.atomic.memcpy/memmove
1364// and llvm.memcpy/memmove
1365class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1366public:
1367 static bool classof(const IntrinsicInst *I) {
1368 switch (I->getIntrinsicID()) {
1369 case Intrinsic::memcpy:
1370 case Intrinsic::memcpy_inline:
1371 case Intrinsic::memmove:
1372 case Intrinsic::memcpy_element_unordered_atomic:
1373 case Intrinsic::memmove_element_unordered_atomic:
1374 return true;
1375 default:
1376 return false;
1377 }
1378 }
1379 static bool classof(const Value *V) {
1381 }
1382};
1383
1384/// This class represents any memcpy intrinsic
1385/// i.e. llvm.element.unordered.atomic.memcpy
1386/// and llvm.memcpy
1388public:
1389 static bool classof(const IntrinsicInst *I) {
1390 switch (I->getIntrinsicID()) {
1391 case Intrinsic::memcpy:
1392 case Intrinsic::memcpy_inline:
1393 case Intrinsic::memcpy_element_unordered_atomic:
1394 return true;
1395 default:
1396 return false;
1397 }
1398 }
1399 static bool classof(const Value *V) {
1401 }
1402};
1403
1404/// This class represents any memmove intrinsic
1405/// i.e. llvm.element.unordered.atomic.memmove
1406/// and llvm.memmove
1408public:
1409 static bool classof(const IntrinsicInst *I) {
1410 switch (I->getIntrinsicID()) {
1411 case Intrinsic::memmove:
1412 case Intrinsic::memmove_element_unordered_atomic:
1413 return true;
1414 default:
1415 return false;
1416 }
1417 }
1418 static bool classof(const Value *V) {
1420 }
1421};
1422
1423/// This represents the llvm.va_start intrinsic.
1425public:
1426 static bool classof(const IntrinsicInst *I) {
1427 return I->getIntrinsicID() == Intrinsic::vastart;
1428 }
1429 static bool classof(const Value *V) {
1431 }
1432
1433 Value *getArgList() const { return getArgOperand(0); }
1434};
1435
1436/// This represents the llvm.va_end intrinsic.
1437class VAEndInst : public IntrinsicInst {
1438public:
1439 static bool classof(const IntrinsicInst *I) {
1440 return I->getIntrinsicID() == Intrinsic::vaend;
1441 }
1442 static bool classof(const Value *V) {
1444 }
1445
1446 Value *getArgList() const { return getArgOperand(0); }
1447};
1448
1449/// This represents the llvm.va_copy intrinsic.
1451public:
1452 static bool classof(const IntrinsicInst *I) {
1453 return I->getIntrinsicID() == Intrinsic::vacopy;
1454 }
1455 static bool classof(const Value *V) {
1457 }
1458
1459 Value *getDest() const { return getArgOperand(0); }
1460 Value *getSrc() const { return getArgOperand(1); }
1461};
1462
1463/// A base class for all instrprof intrinsics.
1465protected:
1466 static bool isCounterBase(const IntrinsicInst &I) {
1467 switch (I.getIntrinsicID()) {
1468 case Intrinsic::instrprof_cover:
1469 case Intrinsic::instrprof_increment:
1470 case Intrinsic::instrprof_increment_step:
1471 case Intrinsic::instrprof_callsite:
1472 case Intrinsic::instrprof_timestamp:
1473 case Intrinsic::instrprof_value_profile:
1474 return true;
1475 }
1476 return false;
1477 }
1478 static bool isMCDCBitmapBase(const IntrinsicInst &I) {
1479 switch (I.getIntrinsicID()) {
1480 case Intrinsic::instrprof_mcdc_parameters:
1481 case Intrinsic::instrprof_mcdc_tvbitmap_update:
1482 return true;
1483 }
1484 return false;
1485 }
1486
1487public:
1488 static bool classof(const Value *V) {
1489 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1490 return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr);
1491 return false;
1492 }
1493
1494 // The name of the instrumented function, assuming it is a global variable.
1497 }
1498
1499 // The "name" operand of the profile instrumentation instruction - this is the
1500 // operand that can be used to relate the instruction to the function it
1501 // belonged to at instrumentation time.
1503
1505
1506 // The hash of the CFG for the instrumented function.
1508};
1509
1510/// A base class for all instrprof counter intrinsics.
1512public:
1513 static bool classof(const Value *V) {
1514 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1515 return InstrProfInstBase::isCounterBase(*Instr);
1516 return false;
1517 }
1518
1519 // The number of counters for the instrumented function.
1521 // The index of the counter that this instruction acts on.
1522 LLVM_ABI ConstantInt *getIndex() const;
1523 LLVM_ABI void setIndex(uint32_t Idx);
1524};
1525
1526/// This represents the llvm.instrprof.cover intrinsic.
1528public:
1529 static bool classof(const IntrinsicInst *I) {
1530 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1531 }
1532 static bool classof(const Value *V) {
1534 }
1535};
1536
1537/// This represents the llvm.instrprof.increment intrinsic.
1539public:
1540 static bool classof(const IntrinsicInst *I) {
1541 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1542 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1543 }
1544 static bool classof(const Value *V) {
1546 }
1547 LLVM_ABI Value *getStep() const;
1548};
1549
1550/// This represents the llvm.instrprof.increment.step intrinsic.
1552public:
1553 static bool classof(const IntrinsicInst *I) {
1554 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1555 }
1556 static bool classof(const Value *V) {
1558 }
1559};
1560
1561/// This represents the llvm.instrprof.callsite intrinsic.
1562/// It is structurally like the increment or step counters, hence the
1563/// inheritance relationship, albeit somewhat tenuous (it's not 'counting' per
1564/// se)
1566public:
1567 static bool classof(const IntrinsicInst *I) {
1568 return I->getIntrinsicID() == Intrinsic::instrprof_callsite;
1569 }
1570 static bool classof(const Value *V) {
1572 }
1573 // We instrument direct calls (but not to intrinsics), or indirect calls.
1574 static bool canInstrumentCallsite(const CallBase &CB) {
1575 return !CB.isInlineAsm() &&
1576 (CB.isIndirectCall() ||
1578 }
1579 LLVM_ABI Value *getCallee() const;
1580 LLVM_ABI void setCallee(Value *Callee);
1581};
1582
1583/// This represents the llvm.instrprof.timestamp intrinsic.
1585public:
1586 static bool classof(const IntrinsicInst *I) {
1587 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1588 }
1589 static bool classof(const Value *V) {
1591 }
1592};
1593
1594/// This represents the llvm.instrprof.value.profile intrinsic.
1596public:
1597 static bool classof(const IntrinsicInst *I) {
1598 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1599 }
1600 static bool classof(const Value *V) {
1602 }
1603
1605
1608 }
1609
1610 // Returns the value site index.
1612};
1613
1614/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1616public:
1617 static bool classof(const IntrinsicInst *I) {
1619 }
1620 static bool classof(const Value *V) {
1622 }
1623
1624 /// \return The number of bits used for the MCDC bitmaps for the instrumented
1625 /// function.
1629
1630 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1631 /// function.
1632 auto getNumBitmapBytes() const {
1633 return alignTo(getNumBitmapBits()->getZExtValue(), CHAR_BIT) / CHAR_BIT;
1634 }
1635};
1636
1637/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1639public:
1640 static bool classof(const IntrinsicInst *I) {
1641 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1642 }
1643 static bool classof(const Value *V) {
1645 }
1646};
1647
1648/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1650public:
1651 static bool classof(const IntrinsicInst *I) {
1652 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1653 }
1654 static bool classof(const Value *V) {
1656 }
1657
1658 /// \return The index of the TestVector Bitmap upon which this intrinsic
1659 /// acts.
1662 }
1663
1664 /// \return The address of the corresponding condition bitmap containing
1665 /// the index of the TestVector to update within the TestVector Bitmap.
1667};
1668
1670public:
1671 static bool classof(const IntrinsicInst *I) {
1672 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1673 }
1674
1675 static bool classof(const Value *V) {
1677 }
1678
1681 }
1682
1684
1687 }
1688
1690};
1691
1693public:
1694 static bool classof(const IntrinsicInst *I) {
1695 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1696 }
1697
1698 static bool classof(const Value *V) {
1700 }
1701
1703 auto *MV =
1705 return cast<MDNode>(MV->getMetadata());
1706 }
1707
1712};
1713
1714/// Common base class for representing values projected from a statepoint.
1715/// Currently, the only projections available are gc.result and gc.relocate.
1717public:
1718 static bool classof(const IntrinsicInst *I) {
1719 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1720 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1721 }
1722
1723 static bool classof(const Value *V) {
1725 }
1726
1727 /// Return true if this relocate is tied to the invoke statepoint.
1728 /// This includes relocates which are on the unwinding path.
1729 bool isTiedToInvoke() const {
1730 const Value *Token = getArgOperand(0);
1731
1732 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1733 }
1734
1735 /// The statepoint with which this gc.relocate is associated.
1736 LLVM_ABI const Value *getStatepoint() const;
1737};
1738
1739/// Represents calls to the gc.relocate intrinsic.
1741public:
1742 static bool classof(const IntrinsicInst *I) {
1743 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1744 }
1745
1746 static bool classof(const Value *V) {
1748 }
1749
1750 /// The index into the associate statepoint's argument list
1751 /// which contains the base pointer of the pointer whose
1752 /// relocation this gc.relocate describes.
1753 unsigned getBasePtrIndex() const {
1754 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1755 }
1756
1757 /// The index into the associate statepoint's argument list which
1758 /// contains the pointer whose relocation this gc.relocate describes.
1759 unsigned getDerivedPtrIndex() const {
1760 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1761 }
1762
1763 LLVM_ABI Value *getBasePtr() const;
1764 LLVM_ABI Value *getDerivedPtr() const;
1765};
1766
1767/// Represents calls to the gc.result intrinsic.
1769public:
1770 static bool classof(const IntrinsicInst *I) {
1771 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1772 }
1773
1774 static bool classof(const Value *V) {
1776 }
1777};
1778
1779
1780/// This represents the llvm.assume intrinsic.
1782public:
1783 static bool classof(const IntrinsicInst *I) {
1784 return I->getIntrinsicID() == Intrinsic::assume;
1785 }
1786 static bool classof(const Value *V) {
1788 }
1789};
1790
1791/// Check if \p ID corresponds to a convergence control intrinsic.
1792static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1793 switch (IntrinsicID) {
1794 default:
1795 return false;
1796 case Intrinsic::experimental_convergence_anchor:
1797 case Intrinsic::experimental_convergence_entry:
1798 case Intrinsic::experimental_convergence_loop:
1799 return true;
1800 }
1801}
1802
1803/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1805public:
1806 static bool classof(const IntrinsicInst *I) {
1807 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1808 }
1809
1810 static bool classof(const Value *V) {
1812 }
1813
1814 bool isAnchor() const {
1815 return getIntrinsicID() == Intrinsic::experimental_convergence_anchor;
1816 }
1817 bool isEntry() const {
1818 return getIntrinsicID() == Intrinsic::experimental_convergence_entry;
1819 }
1820 bool isLoop() const {
1821 return getIntrinsicID() == Intrinsic::experimental_convergence_loop;
1822 }
1823
1828};
1829
1831public:
1832 static bool classof(const IntrinsicInst *I) {
1833 return I->getIntrinsicID() == Intrinsic::structured_alloca;
1834 }
1835
1836 static bool classof(const Value *V) {
1838 }
1839
1841 return getRetAttr(Attribute::ElementType).getValueAsType();
1842 }
1843};
1844
1846public:
1847 static bool classof(const IntrinsicInst *I) {
1848 return I->getIntrinsicID() == Intrinsic::structured_gep;
1849 }
1850
1851 static bool classof(const Value *V) {
1853 }
1854
1855 static unsigned getPointerOperandIndex() { return 0; }
1856
1860
1862 return getParamAttr(0, Attribute::ElementType).getValueAsType();
1863 }
1864
1865 unsigned getNumIndices() const { return arg_size() - 1; }
1866
1867 Value *getIndexOperand(size_t Index) const {
1868 assert(Index < getNumIndices());
1869 return getOperand(Index + 1);
1870 }
1871
1873 Type *CurrentType = getBaseType();
1874 for (unsigned I = 0; I < getNumIndices(); I++) {
1875 if (ArrayType *AT = dyn_cast<ArrayType>(CurrentType)) {
1876 CurrentType = AT->getElementType();
1877 } else if (VectorType *VT = dyn_cast<VectorType>(CurrentType)) {
1878 CurrentType = VT->getElementType();
1879 } else if (StructType *ST = dyn_cast<StructType>(CurrentType)) {
1881 CurrentType = ST->getElementType(CI->getZExtValue());
1882 } else {
1883 // FIXME(Keenuts): add testing reaching those places once initial
1884 // implementation has landed.
1885 llvm_unreachable("unimplemented");
1886 }
1887 }
1888
1889 return CurrentType;
1890 }
1891};
1892
1893} // end namespace llvm
1894
1895#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:215
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file contains the declarations of entities that describe floating point environment and related ...
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
MachineInstr unsigned OpIdx
static unsigned getScalarSizeInBits(Type *Ty)
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
Value * RHS
Class for arbitrary precision integers.
Definition APInt.h:78
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
Definition APInt.h: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)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Class to represent array types.
This represents the llvm.assume intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM_ABI Type * getValueAsType() const
Return the attribute's value as a Type.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
This class represents an intrinsic that is based on a binary operation.
static bool classof(const Value *V)
LLVM_ABI unsigned getNoWrapKind() const
Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
LLVM_ABI bool isSigned() const
Whether the intrinsic is signed or unsigned.
static bool classof(const IntrinsicInst *I)
LLVM_ABI Instruction::BinaryOps getBinaryOp() const
Returns the binary operation underlying the intrinsic.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
bool isInlineAsm() const
Check if this call is an inline asm statement.
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Value * getCalledOperand() const
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Value * getArgOperand(unsigned i) const
void setArgOperand(unsigned i, Value *v)
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
unsigned arg_size() const
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
@ ICMP_SLT
signed less than
Definition InstrTypes.h:769
@ ICMP_UGT
unsigned greater than
Definition InstrTypes.h:763
@ ICMP_SGT
signed greater than
Definition InstrTypes.h:767
@ ICMP_ULT
unsigned less than
Definition InstrTypes.h:765
bool isSigned() const
Definition InstrTypes.h:993
This class represents a ucmp/scmp intrinsic.
static CmpInst::Predicate getGTPredicate(Intrinsic::ID ID)
Value * getRHS() const
CmpInst::Predicate getLTPredicate() const
static CmpInst::Predicate getLTPredicate(Intrinsic::ID ID)
static bool classof(const IntrinsicInst *I)
static bool isSigned(Intrinsic::ID ID)
bool isSigned() const
CmpInst::Predicate getGTPredicate() const
Value * getLHS() const
static bool classof(const Value *V)
This is the shared class of boolean and integer constants.
Definition Constants.h:87
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Definition Constants.h:219
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
Definition Constants.h:168
This is an important base class in LLVM.
Definition Constant.h:43
static LLVM_ABI Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
Constrained floating point compare intrinsics.
LLVM_ABI FCmpInst::Predicate getPredicate() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This is the common base class for constrained floating point intrinsics.
LLVM_ABI std::optional< fp::ExceptionBehavior > getExceptionBehavior() const
LLVM_ABI std::optional< RoundingMode > getRoundingMode() const
LLVM_ABI unsigned getNonMetadataArgCount() const
static LLVM_ABI bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
LLVM_ABI bool isDefaultFPEnvironment() const
Represents calls to the llvm.experimintal.convergence.* intrinsics.
static bool classof(const Value *V)
static LLVM_ABI ConvergenceControlInst * CreateAnchor(BasicBlock &BB)
static LLVM_ABI ConvergenceControlInst * CreateLoop(BasicBlock &BB, ConvergenceControlInst *Parent)
static LLVM_ABI ConvergenceControlInst * CreateEntry(BasicBlock &BB)
static bool classof(const IntrinsicInst *I)
DWARF expression.
DbgVariableFragmentInfo FragmentInfo
static LLVM_ABI std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
This represents the llvm.dbg.assign instruction.
DIAssignID * getAssignID() const
LLVM_ABI void setValue(Value *V)
static bool classof(const Value *V)
LLVM_ABI void setAssignId(DIAssignID *New)
LLVM_ABI void setKillAddress()
Kill the address component.
LLVM_ABI bool isKillAddress() const
Check whether this kills the address component.
Metadata * getRawAddress() const
DIExpression * getAddressExpression() const
LLVM_ABI Value * getAddress() const
static bool classof(const IntrinsicInst *I)
Metadata * getRawAddressExpression() const
Metadata * getRawAssignID() const
LLVM_ABI void setAddress(Value *V)
void setAddressExpression(DIExpression *NewExpr)
This represents the llvm.dbg.declare instruction.
static bool classof(const Value *V)
Value * getAddress() const
static bool classof(const IntrinsicInst *I)
This is the common base class for debug info intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.dbg.label instruction.
Metadata * getRawLabel() const
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
DILabel * getLabel() const
static bool classof(const Value *V)
void setLabel(DILabel *NewLabel)
This represents the llvm.dbg.value instruction.
iterator_range< location_op_iterator > getValues() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Value * getValue(unsigned OpIdx=0) const
This is the common base class for debug info intrinsics for variables.
DIExpression::FragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
void setVariable(DILocalVariable *NewVar)
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
LLVM_ABI void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
bool isValueOfVariable() const
Determine if this describes the value of a local variable.
void setRawLocation(Metadata *Location)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
std::optional< DIExpression::FragmentInfo > getFragment() const
Get the FragmentInfo for the variable.
static bool classof(const Value *V)
void setExpression(DIExpression *NewExpr)
Metadata * getRawLocation() const
DILocalVariable * getVariable() const
unsigned getNumVariableLocationOps() const
bool isAddressOfVariable() const
Does this describe the address of a local variable.
void setOperand(unsigned i, Value *v)
Metadata * getRawVariable() const
static bool classof(const IntrinsicInst *I)
LLVM_ABI std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
DIExpression * getExpression() const
void setArgOperand(unsigned i, Value *v)
Metadata * getRawExpression() const
RawLocationWrapper getWrappedLocation() const
Class representing an expression and its matching format.
Common base class for representing values projected from a statepoint.
LLVM_ABI const Value * getStatepoint() const
The statepoint with which this gc.relocate is associated.
bool isTiedToInvoke() const
Return true if this relocate is tied to the invoke statepoint.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Represents calls to the gc.relocate intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
LLVM_ABI Value * getBasePtr() const
unsigned getBasePtrIndex() const
The index into the associate statepoint's argument list which contains the base pointer of the pointe...
LLVM_ABI Value * getDerivedPtr() const
unsigned getDerivedPtrIndex() const
The index into the associate statepoint's argument list which contains the pointer whose relocation t...
Represents calls to the gc.result intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.callsite intrinsic.
LLVM_ABI void setCallee(Value *Callee)
LLVM_ABI Value * getCallee() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool canInstrumentCallsite(const CallBase &CB)
A base class for all instrprof counter intrinsics.
static bool classof(const Value *V)
LLVM_ABI ConstantInt * getIndex() const
LLVM_ABI void setIndex(uint32_t Idx)
LLVM_ABI ConstantInt * getNumCounters() const
This represents the llvm.instrprof.cover intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.instrprof.increment.step intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.increment intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
LLVM_ABI Value * getStep() const
A base class for all instrprof intrinsics.
static bool classof(const Value *V)
void setNameValue(Value *V)
GlobalVariable * getName() const
ConstantInt * getHash() const
Value * getNameValue() const
static bool isCounterBase(const IntrinsicInst &I)
static bool isMCDCBitmapBase(const IntrinsicInst &I)
A base class for instrprof mcdc intrinsics that require global bitmap bytes.
ConstantInt * getNumBitmapBits() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.mcdc.parameters intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
ConstantInt * getBitmapIndex() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.instrprof.timestamp intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.value.profile intrinsic.
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
ConstantInt * getValueKind() const
static bool classof(const Value *V)
A wrapper class for inspecting calls to intrinsic functions.
bool isAssumeLikeIntrinsic() const
Checks if the intrinsic is an annotation.
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
IntrinsicInst(const IntrinsicInst &)=delete
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
bool isCommutative() const
Return true if swapping the first two arguments to the intrinsic produces the same result.
bool isCommutableOperand(unsigned Op) const
Return true if the operand is commutable.
static bool classof(const Value *V)
IntrinsicInst & operator=(const IntrinsicInst &)=delete
static bool classof(const CallInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
bool isAssociative() const
This is the common base class for lifetime intrinsics.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Metadata node.
Definition Metadata.h:1069
LLVMContext & getContext() const
Definition Metadata.h:1233
This class wraps the llvm.memcpy intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memory intrinsics.
const Use & getRawDestUse() const
Value * getLength() const
Value * getRawDest() const
void setDestAlignment(Align Alignment)
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions (including addrspacecast) that ...
void setDestAlignment(MaybeAlign Alignment)
void setLength(uint64_t L)
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
MaybeAlign getDestAlign() const
const Use & getLengthUse() const
unsigned getDestAddressSpace() const
std::optional< APInt > getLengthInBytes() const
This is the common base class for memset/memcpy/memmove.
ConstantInt * getVolatileCst() const
void setVolatile(Constant *V)
bool isForceInlined() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
bool isVolatile() const
This class wraps the llvm.memmove intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memset intrinsics.
void setValue(Value *Val)
const Use & getValueUse() const
Value * getValue() const
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This class wraps the llvm.experimental.memset.pattern intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getVolatileCst() const
void setVolatile(Constant *V)
Common base class for all memory transfer intrinsics.
void setSource(Value *Ptr)
Value * getRawSource() const
Return the arguments to the instruction.
unsigned getSourceAddressSpace() const
MaybeAlign getSourceAlign() const
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it,...
void setSourceAlignment(MaybeAlign Alignment)
void setSourceAlignment(Align Alignment)
const Use & getRawSourceUse() const
This class wraps the llvm.memcpy/memmove intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:110
Root of the metadata hierarchy.
Definition Metadata.h:64
This class represents min/max intrinsics.
static bool classof(const Value *V)
static Constant * getSaturationPoint(Intrinsic::ID ID, Type *Ty)
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
APInt getSaturationPoint(unsigned numBits) const
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits)
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
Value * getLHS() const
APInt getIdentity() const
Returns the identity value for this min/max intrinsic, such that minmax(X, Identity) == X.
Value * getRHS() const
bool isMin() const
Whether the intrinsic is a smin or a umin.
static ICmpInst::Predicate getPredicate(Intrinsic::ID ID)
Returns the comparison predicate underlying the intrinsic.
ICmpInst::Predicate getPredicate() const
Returns the comparison predicate underlying the intrinsic.
static bool isMin(Intrinsic::ID ID)
Whether the intrinsic is a smin or umin.
static bool isSigned(Intrinsic::ID ID)
Whether the intrinsic is signed or unsigned.
static APInt getIdentity(Intrinsic::ID ID, unsigned NumBits)
Returns the identity value for this min/max intrinsic, such that minmax(X, Identity) == X.
bool isMax() const
Whether the intrinsic is a smax or a umax.
static bool classof(const IntrinsicInst *I)
bool isSigned() const
Whether the intrinsic is signed or unsigned.
Constant * getSaturationPoint(Type *Ty) const
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
static bool classof(const IntrinsicInst *I)
void setScopeList(MDNode *ScopeList)
static bool classof(const Value *V)
MDNode * getScopeList() const
A discriminated union of two or more pointer types, with the discriminator in the low bits of the poi...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
ConstantInt * getAttributes() const
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getFactor() const
ConstantInt * getFuncGuid() const
Lightweight class that wraps the location operand metadata of a debug intrinsic.
friend bool operator<=(const RawLocationWrapper &A, const RawLocationWrapper &B)
Metadata * getRawLocation() const
friend bool operator>(const RawLocationWrapper &A, const RawLocationWrapper &B)
RawLocationWrapper(Metadata *RawLocation)
friend bool operator<(const RawLocationWrapper &A, const RawLocationWrapper &B)
friend bool operator==(const RawLocationWrapper &A, const RawLocationWrapper &B)
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
bool isKillLocation(const DIExpression *Expression) const
friend bool operator!=(const RawLocationWrapper &A, const RawLocationWrapper &B)
unsigned getNumVariableLocationOps() const
friend bool operator>=(const RawLocationWrapper &A, const RawLocationWrapper &B)
Represents a saturating add/sub intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Class to represent struct types.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
unsigned getNumIndices() const
static unsigned getPointerOperandIndex()
static bool classof(const Value *V)
Value * getPointerOperand() const
Type * getResultElementType() const
Value * getIndexOperand(size_t Index) const
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
void setOperand(unsigned i, Value *Val)
Definition User.h:212
Value * getOperand(unsigned i) const
Definition User.h:207
This represents the llvm.va_copy intrinsic.
Value * getSrc() const
static bool classof(const Value *V)
Value * getDest() const
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_end intrinsic.
Value * getArgList() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_start intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Value * getArgList() const
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:459
Value * getValue() const
Definition Metadata.h:499
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:255
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:258
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition Value.cpp:713
Base class of all SIMD vector types.
Represents an op.with.overflow intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterator.h:80
A range adaptor for a pair of iterators.
bool operator==(const location_op_iterator &RHS) const
location_op_iterator & operator=(const location_op_iterator &R)
location_op_iterator(ValueAsMetadata **MultiIter)
location_op_iterator(const location_op_iterator &R)
location_op_iterator & operator++()
location_op_iterator(ValueAsMetadata *SingleIter)
location_op_iterator & operator--()
const Value * operator*() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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:42
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:1746
static bool isLifetimeIntrinsic(Intrinsic::ID ID)
Check if ID corresponds to a lifetime intrinsic.
static bool isDbgInfoIntrinsic(Intrinsic::ID ID)
Check if ID corresponds to a debug info intrinsic.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:144
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
static bool isConvergenceControlIntrinsic(unsigned IntrinsicID)
Check if ID corresponds to a convergence control intrinsic.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:106