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