LLVM 19.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"
36#include <cassert>
37#include <cstdint>
38#include <optional>
39
40namespace llvm {
41
42class Metadata;
43
44/// A wrapper class for inspecting calls to intrinsic functions.
45/// This allows the standard isa/dyncast/cast functionality to work with calls
46/// to intrinsic functions.
47class IntrinsicInst : public CallInst {
48public:
49 IntrinsicInst() = delete;
50 IntrinsicInst(const IntrinsicInst &) = delete;
52
53 /// Return the intrinsic ID of this intrinsic.
56 }
57
58 bool isAssociative() const {
59 switch (getIntrinsicID()) {
60 case Intrinsic::smax:
61 case Intrinsic::smin:
62 case Intrinsic::umax:
63 case Intrinsic::umin:
64 return true;
65 default:
66 return false;
67 }
68 }
69
70 /// Return true if swapping the first two arguments to the intrinsic produces
71 /// the same result.
72 bool isCommutative() const {
73 switch (getIntrinsicID()) {
74 case Intrinsic::maxnum:
75 case Intrinsic::minnum:
76 case Intrinsic::maximum:
77 case Intrinsic::minimum:
78 case Intrinsic::smax:
79 case Intrinsic::smin:
80 case Intrinsic::umax:
81 case Intrinsic::umin:
82 case Intrinsic::sadd_sat:
83 case Intrinsic::uadd_sat:
84 case Intrinsic::sadd_with_overflow:
85 case Intrinsic::uadd_with_overflow:
86 case Intrinsic::smul_with_overflow:
87 case Intrinsic::umul_with_overflow:
88 case Intrinsic::smul_fix:
89 case Intrinsic::umul_fix:
90 case Intrinsic::smul_fix_sat:
91 case Intrinsic::umul_fix_sat:
92 case Intrinsic::fma:
93 case Intrinsic::fmuladd:
94 return true;
95 default:
96 return false;
97 }
98 }
99
100 /// Checks if the intrinsic is an annotation.
102 switch (getIntrinsicID()) {
103 default: break;
104 case Intrinsic::assume:
105 case Intrinsic::sideeffect:
106 case Intrinsic::pseudoprobe:
107 case Intrinsic::dbg_assign:
108 case Intrinsic::dbg_declare:
109 case Intrinsic::dbg_value:
110 case Intrinsic::dbg_label:
111 case Intrinsic::invariant_start:
112 case Intrinsic::invariant_end:
113 case Intrinsic::lifetime_start:
114 case Intrinsic::lifetime_end:
115 case Intrinsic::experimental_noalias_scope_decl:
116 case Intrinsic::objectsize:
117 case Intrinsic::ptr_annotation:
118 case Intrinsic::var_annotation:
119 return true;
120 }
121 return false;
122 }
123
124 /// Check if the intrinsic might lower into a regular function call in the
125 /// course of IR transformations
126 static bool mayLowerToFunctionCall(Intrinsic::ID IID);
127
128 /// Methods for support type inquiry through isa, cast, and dyn_cast:
129 static bool classof(const CallInst *I) {
130 if (const Function *CF = I->getCalledFunction())
131 return CF->isIntrinsic();
132 return false;
133 }
134 static bool classof(const Value *V) {
135 return isa<CallInst>(V) && classof(cast<CallInst>(V));
136 }
137};
138
139/// Check if \p ID corresponds to a lifetime intrinsic.
141 switch (ID) {
142 case Intrinsic::lifetime_start:
143 case Intrinsic::lifetime_end:
144 return true;
145 default:
146 return false;
147 }
148}
149
150/// This is the common base class for lifetime intrinsics.
152public:
153 /// \name Casting methods
154 /// @{
155 static bool classof(const IntrinsicInst *I) {
156 return isLifetimeIntrinsic(I->getIntrinsicID());
157 }
158 static bool classof(const Value *V) {
159 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
160 }
161 /// @}
162};
163
164/// Check if \p ID corresponds to a debug info intrinsic.
166 switch (ID) {
167 case Intrinsic::dbg_declare:
168 case Intrinsic::dbg_value:
169 case Intrinsic::dbg_label:
170 case Intrinsic::dbg_assign:
171 return true;
172 default:
173 return false;
174 }
175}
176
177/// This is the common base class for debug info intrinsics.
179public:
180 /// \name Casting methods
181 /// @{
182 static bool classof(const IntrinsicInst *I) {
183 return isDbgInfoIntrinsic(I->getIntrinsicID());
184 }
185 static bool classof(const Value *V) {
186 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
187 }
188 /// @}
189};
190
191// Iterator for ValueAsMetadata that internally uses direct pointer iteration
192// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
193// ValueAsMetadata .
195 : public iterator_facade_base<location_op_iterator,
196 std::bidirectional_iterator_tag, Value *> {
198
199public:
200 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
201 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
202
205 I = R.I;
206 return *this;
207 }
208 bool operator==(const location_op_iterator &RHS) const { return I == RHS.I; }
209 const Value *operator*() const {
210 ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
211 ? cast<ValueAsMetadata *>(I)
212 : *cast<ValueAsMetadata **>(I);
213 return VAM->getValue();
214 };
216 ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
217 ? cast<ValueAsMetadata *>(I)
218 : *cast<ValueAsMetadata **>(I);
219 return VAM->getValue();
220 }
222 if (isa<ValueAsMetadata *>(I))
223 I = cast<ValueAsMetadata *>(I) + 1;
224 else
225 I = cast<ValueAsMetadata **>(I) + 1;
226 return *this;
227 }
229 if (isa<ValueAsMetadata *>(I))
230 I = cast<ValueAsMetadata *>(I) - 1;
231 else
232 I = cast<ValueAsMetadata **>(I) - 1;
233 return *this;
234 }
235};
236
237/// Lightweight class that wraps the location operand metadata of a debug
238/// intrinsic. The raw location may be a ValueAsMetadata, an empty MDTuple,
239/// or a DIArgList.
241 Metadata *RawLocation = nullptr;
242
243public:
245 explicit RawLocationWrapper(Metadata *RawLocation)
246 : RawLocation(RawLocation) {
247 // Allow ValueAsMetadata, empty MDTuple, DIArgList.
248 assert(RawLocation && "unexpected null RawLocation");
249 assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
250 (isa<MDNode>(RawLocation) &&
251 !cast<MDNode>(RawLocation)->getNumOperands()));
252 }
253 Metadata *getRawLocation() const { return RawLocation; }
254 /// Get the locations corresponding to the variable referenced by the debug
255 /// info intrinsic. Depending on the intrinsic, this could be the
256 /// variable's value or its address.
258 Value *getVariableLocationOp(unsigned OpIdx) const;
259 unsigned getNumVariableLocationOps() const {
260 if (hasArgList())
261 return cast<DIArgList>(getRawLocation())->getArgs().size();
262 return 1;
263 }
264 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
266 // Check for "kill" sentinel values.
267 // Non-variadic: empty metadata.
268 if (!hasArgList() && isa<MDNode>(getRawLocation()))
269 return true;
270 // Variadic: empty DIArgList with empty expression.
271 if (getNumVariableLocationOps() == 0 && !Expression->isComplex())
272 return true;
273 // Variadic and non-variadic: Interpret expressions using undef or poison
274 // values as kills.
275 return any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
276 }
277
278 friend bool operator==(const RawLocationWrapper &A,
279 const RawLocationWrapper &B) {
280 return A.RawLocation == B.RawLocation;
281 }
282 friend bool operator!=(const RawLocationWrapper &A,
283 const RawLocationWrapper &B) {
284 return !(A == B);
285 }
286 friend bool operator>(const RawLocationWrapper &A,
287 const RawLocationWrapper &B) {
288 return A.RawLocation > B.RawLocation;
289 }
290 friend bool operator>=(const RawLocationWrapper &A,
291 const RawLocationWrapper &B) {
292 return A.RawLocation >= B.RawLocation;
293 }
294 friend bool operator<(const RawLocationWrapper &A,
295 const RawLocationWrapper &B) {
296 return A.RawLocation < B.RawLocation;
297 }
298 friend bool operator<=(const RawLocationWrapper &A,
299 const RawLocationWrapper &B) {
300 return A.RawLocation <= B.RawLocation;
301 }
302};
303
304/// This is the common base class for debug info intrinsics for variables.
306public:
307 /// Get the locations corresponding to the variable referenced by the debug
308 /// info intrinsic. Depending on the intrinsic, this could be the
309 /// variable's value or its address.
311
312 Value *getVariableLocationOp(unsigned OpIdx) const;
313
314 void replaceVariableLocationOp(Value *OldValue, Value *NewValue);
315 void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
316 /// Adding a new location operand will always result in this intrinsic using
317 /// an ArgList, and must always be accompanied by a new expression that uses
318 /// the new operand.
321
323 setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
324 }
325
328 }
329
330 unsigned getNumVariableLocationOps() const {
332 }
333
334 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
335
336 /// Does this describe the address of a local variable. True for dbg.declare,
337 /// but not dbg.value, which describes its value, or dbg.assign, which
338 /// describes a combination of the variable's value and address.
339 bool isAddressOfVariable() const {
340 return getIntrinsicID() == Intrinsic::dbg_declare;
341 }
342
344 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
345 // this set anymore.
346 SmallPtrSet<Value *, 4> RemovedValues;
347 for (Value *OldValue : location_ops()) {
348 if (!RemovedValues.insert(OldValue).second)
349 continue;
350 Value *Poison = PoisonValue::get(OldValue->getType());
351 replaceVariableLocationOp(OldValue, Poison);
352 }
353 }
354
355 bool isKillLocation() const {
357 }
358
360 return cast<DILocalVariable>(getRawVariable());
361 }
362
364 return cast<DIExpression>(getRawExpression());
365 }
366
368 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
369 }
370
373 }
374
376 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
377 }
378
380 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
381 }
382
383 /// Use of this should generally be avoided; instead,
384 /// replaceVariableLocationOp and addVariableLocationOps should be used where
385 /// possible to avoid creating invalid state.
386 void setRawLocation(Metadata *Location) {
387 return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
388 }
389
390 /// Get the size (in bits) of the variable, or fragment of the variable that
391 /// is described.
392 std::optional<uint64_t> getFragmentSizeInBits() const;
393
394 /// Get the FragmentInfo for the variable.
395 std::optional<DIExpression::FragmentInfo> getFragment() const {
396 return getExpression()->getFragmentInfo();
397 }
398
399 /// Get the FragmentInfo for the variable if it exists, otherwise return a
400 /// FragmentInfo that covers the entire variable if the variable size is
401 /// known, otherwise return a zero-sized fragment.
403 DIExpression::FragmentInfo VariableSlice(0, 0);
404 // Get the fragment or variable size, or zero.
405 if (auto Sz = getFragmentSizeInBits())
406 VariableSlice.SizeInBits = *Sz;
407 if (auto Frag = getExpression()->getFragmentInfo())
408 VariableSlice.OffsetInBits = Frag->OffsetInBits;
409 return VariableSlice;
410 }
411
412 /// \name Casting methods
413 /// @{
414 static bool classof(const IntrinsicInst *I) {
415 switch (I->getIntrinsicID()) {
416 case Intrinsic::dbg_declare:
417 case Intrinsic::dbg_value:
418 case Intrinsic::dbg_assign:
419 return true;
420 default:
421 return false;
422 }
423 }
424 static bool classof(const Value *V) {
425 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
426 }
427 /// @}
428protected:
429 void setArgOperand(unsigned i, Value *v) {
431 }
432 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
433};
434
435/// This represents the llvm.dbg.declare instruction.
437public:
438 Value *getAddress() const {
440 "dbg.declare must have exactly 1 location operand.");
441 return getVariableLocationOp(0);
442 }
443
444 /// \name Casting methods
445 /// @{
446 static bool classof(const IntrinsicInst *I) {
447 return I->getIntrinsicID() == Intrinsic::dbg_declare;
448 }
449 static bool classof(const Value *V) {
450 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
451 }
452 /// @}
453};
454
455/// This represents the llvm.dbg.value instruction.
457public:
458 // The default argument should only be used in ISel, and the default option
459 // should be removed once ISel support for multiple location ops is complete.
460 Value *getValue(unsigned OpIdx = 0) const {
461 return getVariableLocationOp(OpIdx);
462 }
464 return location_ops();
465 }
466
467 /// \name Casting methods
468 /// @{
469 static bool classof(const IntrinsicInst *I) {
470 return I->getIntrinsicID() == Intrinsic::dbg_value ||
471 I->getIntrinsicID() == Intrinsic::dbg_assign;
472 }
473 static bool classof(const Value *V) {
474 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
475 }
476 /// @}
477};
478
479/// This represents the llvm.dbg.assign instruction.
481 enum Operands {
482 OpValue,
483 OpVar,
484 OpExpr,
485 OpAssignID,
486 OpAddress,
487 OpAddressExpr,
488 };
489
490public:
491 Value *getAddress() const;
493 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
494 }
496 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
497 }
498 DIAssignID *getAssignID() const { return cast<DIAssignID>(getRawAssignID()); }
500 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
501 }
503 return cast<DIExpression>(getRawAddressExpression());
504 }
506 setArgOperand(OpAddressExpr,
507 MetadataAsValue::get(NewExpr->getContext(), NewExpr));
508 }
509 void setAssignId(DIAssignID *New);
510 void setAddress(Value *V);
511 /// Kill the address component.
512 void setKillAddress();
513 /// Check whether this kills the address component. This doesn't take into
514 /// account the position of the intrinsic, therefore a returned value of false
515 /// does not guarentee the address is a valid location for the variable at the
516 /// intrinsic's position in IR.
517 bool isKillAddress() const;
518 void setValue(Value *V);
519 /// \name Casting methods
520 /// @{
521 static bool classof(const IntrinsicInst *I) {
522 return I->getIntrinsicID() == Intrinsic::dbg_assign;
523 }
524 static bool classof(const Value *V) {
525 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
526 }
527 /// @}
528};
529
530/// This represents the llvm.dbg.label instruction.
532public:
533 DILabel *getLabel() const { return cast<DILabel>(getRawLabel()); }
534 void setLabel(DILabel *NewLabel) {
536 }
537
539 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
540 }
541
542 /// Methods for support type inquiry through isa, cast, and dyn_cast:
543 /// @{
544 static bool classof(const IntrinsicInst *I) {
545 return I->getIntrinsicID() == Intrinsic::dbg_label;
546 }
547 static bool classof(const Value *V) {
548 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
549 }
550 /// @}
551};
552
553/// This is the common base class for vector predication intrinsics.
555public:
556 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
557 /// \p Params. Additionally, the load and gather intrinsics require
558 /// \p ReturnType to be specified.
560 Type *ReturnType,
561 ArrayRef<Value *> Params);
562
563 static std::optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
564 static std::optional<unsigned> getVectorLengthParamPos(
565 Intrinsic::ID IntrinsicID);
566
567 /// The llvm.vp.* intrinsics for this instruction Opcode
568 static Intrinsic::ID getForOpcode(unsigned OC);
569
570 // Whether \p ID is a VP intrinsic ID.
571 static bool isVPIntrinsic(Intrinsic::ID);
572
573 /// \return The mask parameter or nullptr.
574 Value *getMaskParam() const;
575 void setMaskParam(Value *);
576
577 /// \return The vector length parameter or nullptr.
580
581 /// \return Whether the vector length param can be ignored.
582 bool canIgnoreVectorLengthParam() const;
583
584 /// \return The static element count (vector number of elements) the vector
585 /// length parameter applies to.
587
588 /// \return The alignment of the pointer used by this load/store/gather or
589 /// scatter.
591 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
592
593 /// \return The pointer operand of this load,store, gather or scatter.
595 static std::optional<unsigned> getMemoryPointerParamPos(Intrinsic::ID);
596
597 /// \return The data (payload) operand of this store or scatter.
598 Value *getMemoryDataParam() const;
599 static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
600
601 // Methods for support type inquiry through isa, cast, and dyn_cast:
602 static bool classof(const IntrinsicInst *I) {
603 return isVPIntrinsic(I->getIntrinsicID());
604 }
605 static bool classof(const Value *V) {
606 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
607 }
608
609 // Equivalent non-predicated opcode
610 std::optional<unsigned> getFunctionalOpcode() const {
612 }
613
614 // Equivalent non-predicated intrinsic ID
615 std::optional<unsigned> getFunctionalIntrinsicID() const {
617 }
618
619 // Equivalent non-predicated constrained ID
620 std::optional<unsigned> getConstrainedIntrinsicID() const {
622 }
623
624 // Equivalent non-predicated opcode
625 static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
626
627 // Equivalent non-predicated intrinsic ID
628 static std::optional<Intrinsic::ID>
630
631 // Equivalent non-predicated constrained ID
632 static std::optional<Intrinsic::ID>
634};
635
636/// This represents vector predication reduction intrinsics.
638public:
639 static bool isVPReduction(Intrinsic::ID ID);
640
641 unsigned getStartParamPos() const;
642 unsigned getVectorParamPos() const;
643
644 static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
645 static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
646
647 /// Methods for support type inquiry through isa, cast, and dyn_cast:
648 /// @{
649 static bool classof(const IntrinsicInst *I) {
650 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
651 }
652 static bool classof(const Value *V) {
653 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
654 }
655 /// @}
656};
657
659public:
660 static bool isVPCast(Intrinsic::ID ID);
661
662 /// Methods for support type inquiry through isa, cast, and dyn_cast:
663 /// @{
664 static bool classof(const IntrinsicInst *I) {
665 return VPCastIntrinsic::isVPCast(I->getIntrinsicID());
666 }
667 static bool classof(const Value *V) {
668 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
669 }
670 /// @}
671};
672
674public:
675 static bool isVPCmp(Intrinsic::ID ID);
676
678
679 /// Methods for support type inquiry through isa, cast, and dyn_cast:
680 /// @{
681 static bool classof(const IntrinsicInst *I) {
682 return VPCmpIntrinsic::isVPCmp(I->getIntrinsicID());
683 }
684 static bool classof(const Value *V) {
685 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
686 }
687 /// @}
688};
689
691public:
692 static bool isVPBinOp(Intrinsic::ID ID);
693
694 /// Methods for support type inquiry through isa, cast, and dyn_cast:
695 /// @{
696 static bool classof(const IntrinsicInst *I) {
697 return VPBinOpIntrinsic::isVPBinOp(I->getIntrinsicID());
698 }
699 static bool classof(const Value *V) {
700 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
701 }
702 /// @}
703};
704
705
706/// This is the common base class for constrained floating point intrinsics.
708public:
709 bool isUnaryOp() const;
710 bool isTernaryOp() const;
711 std::optional<RoundingMode> getRoundingMode() const;
712 std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
713 bool isDefaultFPEnvironment() const;
714
715 // Methods for support type inquiry through isa, cast, and dyn_cast:
716 static bool classof(const IntrinsicInst *I);
717 static bool classof(const Value *V) {
718 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
719 }
720};
721
722/// Constrained floating point compare intrinsics.
724public:
726 bool isSignaling() const {
727 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
728 }
729
730 // Methods for support type inquiry through isa, cast, and dyn_cast:
731 static bool classof(const IntrinsicInst *I) {
732 switch (I->getIntrinsicID()) {
733 case Intrinsic::experimental_constrained_fcmp:
734 case Intrinsic::experimental_constrained_fcmps:
735 return true;
736 default:
737 return false;
738 }
739 }
740 static bool classof(const Value *V) {
741 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
742 }
743};
744
745/// This class represents min/max intrinsics.
747public:
748 static bool classof(const IntrinsicInst *I) {
749 switch (I->getIntrinsicID()) {
750 case Intrinsic::umin:
751 case Intrinsic::umax:
752 case Intrinsic::smin:
753 case Intrinsic::smax:
754 return true;
755 default:
756 return false;
757 }
758 }
759 static bool classof(const Value *V) {
760 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
761 }
762
763 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
764 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
765
766 /// Returns the comparison predicate underlying the intrinsic.
768 switch (ID) {
769 case Intrinsic::umin:
771 case Intrinsic::umax:
773 case Intrinsic::smin:
775 case Intrinsic::smax:
777 default:
778 llvm_unreachable("Invalid intrinsic");
779 }
780 }
781
782 /// Returns the comparison predicate underlying the intrinsic.
785 }
786
787 /// Whether the intrinsic is signed or unsigned.
788 static bool isSigned(Intrinsic::ID ID) {
790 };
791
792 /// Whether the intrinsic is signed or unsigned.
793 bool isSigned() const { return isSigned(getIntrinsicID()); };
794
795 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
796 /// so there is a certain threshold value, upon reaching which,
797 /// their value can no longer change. Return said threshold.
798 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
799 switch (ID) {
800 case Intrinsic::umin:
801 return APInt::getMinValue(numBits);
802 case Intrinsic::umax:
803 return APInt::getMaxValue(numBits);
804 case Intrinsic::smin:
805 return APInt::getSignedMinValue(numBits);
806 case Intrinsic::smax:
807 return APInt::getSignedMaxValue(numBits);
808 default:
809 llvm_unreachable("Invalid intrinsic");
810 }
811 }
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 APInt getSaturationPoint(unsigned numBits) const {
817 return getSaturationPoint(getIntrinsicID(), numBits);
818 }
819
820 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
821 /// so there is a certain threshold value, upon reaching which,
822 /// their value can no longer change. Return said threshold.
826 }
827
828 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
829 /// so there is a certain threshold value, upon reaching which,
830 /// their value can no longer change. Return said threshold.
833 }
834};
835
836/// This class represents an intrinsic that is based on a binary operation.
837/// This includes op.with.overflow and saturating add/sub intrinsics.
839public:
840 static bool classof(const IntrinsicInst *I) {
841 switch (I->getIntrinsicID()) {
842 case Intrinsic::uadd_with_overflow:
843 case Intrinsic::sadd_with_overflow:
844 case Intrinsic::usub_with_overflow:
845 case Intrinsic::ssub_with_overflow:
846 case Intrinsic::umul_with_overflow:
847 case Intrinsic::smul_with_overflow:
848 case Intrinsic::uadd_sat:
849 case Intrinsic::sadd_sat:
850 case Intrinsic::usub_sat:
851 case Intrinsic::ssub_sat:
852 return true;
853 default:
854 return false;
855 }
856 }
857 static bool classof(const Value *V) {
858 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
859 }
860
861 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
862 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
863
864 /// Returns the binary operation underlying the intrinsic.
866
867 /// Whether the intrinsic is signed or unsigned.
868 bool isSigned() const;
869
870 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
871 unsigned getNoWrapKind() const;
872};
873
874/// Represents an op.with.overflow intrinsic.
876public:
877 static bool classof(const IntrinsicInst *I) {
878 switch (I->getIntrinsicID()) {
879 case Intrinsic::uadd_with_overflow:
880 case Intrinsic::sadd_with_overflow:
881 case Intrinsic::usub_with_overflow:
882 case Intrinsic::ssub_with_overflow:
883 case Intrinsic::umul_with_overflow:
884 case Intrinsic::smul_with_overflow:
885 return true;
886 default:
887 return false;
888 }
889 }
890 static bool classof(const Value *V) {
891 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
892 }
893};
894
895/// Represents a saturating add/sub intrinsic.
897public:
898 static bool classof(const IntrinsicInst *I) {
899 switch (I->getIntrinsicID()) {
900 case Intrinsic::uadd_sat:
901 case Intrinsic::sadd_sat:
902 case Intrinsic::usub_sat:
903 case Intrinsic::ssub_sat:
904 return true;
905 default:
906 return false;
907 }
908 }
909 static bool classof(const Value *V) {
910 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
911 }
912};
913
914/// Common base class for all memory intrinsics. Simply provides
915/// common methods.
916/// Written as CRTP to avoid a common base class amongst the
917/// three atomicity hierarchies.
918template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
919private:
920 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
921
922public:
923 Value *getRawDest() const {
924 return const_cast<Value *>(getArgOperand(ARG_DEST));
925 }
926 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
927 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
928
929 Value *getLength() const {
930 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
931 }
932 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
933 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
934
935 /// This is just like getRawDest, but it strips off any cast
936 /// instructions (including addrspacecast) that feed it, giving the
937 /// original input. The returned value is guaranteed to be a pointer.
938 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
939
940 unsigned getDestAddressSpace() const {
941 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
942 }
943
944 /// FIXME: Remove this function once transition to Align is over.
945 /// Use getDestAlign() instead.
946 LLVM_DEPRECATED("Use getDestAlign() instead", "getDestAlign")
948 if (auto MA = getParamAlign(ARG_DEST))
949 return MA->value();
950 return 0;
951 }
952 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
953
954 /// Set the specified arguments of the instruction.
956 assert(getRawDest()->getType() == Ptr->getType() &&
957 "setDest called with pointer of wrong type!");
958 setArgOperand(ARG_DEST, Ptr);
959 }
960
961 void setDestAlignment(MaybeAlign Alignment) {
962 removeParamAttr(ARG_DEST, Attribute::Alignment);
963 if (Alignment)
964 addParamAttr(ARG_DEST,
966 }
967 void setDestAlignment(Align Alignment) {
968 removeParamAttr(ARG_DEST, Attribute::Alignment);
969 addParamAttr(ARG_DEST,
971 }
972
973 void setLength(Value *L) {
974 assert(getLength()->getType() == L->getType() &&
975 "setLength called with value of wrong type!");
976 setArgOperand(ARG_LENGTH, L);
977 }
978};
979
980/// Common base class for all memory transfer intrinsics. Simply provides
981/// common methods.
982template <class BaseCL> class MemTransferBase : public BaseCL {
983private:
984 enum { ARG_SOURCE = 1 };
985
986public:
987 /// Return the arguments to the instruction.
989 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
990 }
991 const Use &getRawSourceUse() const {
992 return BaseCL::getArgOperandUse(ARG_SOURCE);
993 }
994 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
995
996 /// This is just like getRawSource, but it strips off any cast
997 /// instructions that feed it, giving the original input. The returned
998 /// value is guaranteed to be a pointer.
1000
1001 unsigned getSourceAddressSpace() const {
1002 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
1003 }
1004
1005 /// FIXME: Remove this function once transition to Align is over.
1006 /// Use getSourceAlign() instead.
1007 LLVM_DEPRECATED("Use getSourceAlign() instead", "getSourceAlign")
1009 if (auto MA = BaseCL::getParamAlign(ARG_SOURCE))
1010 return MA->value();
1011 return 0;
1012 }
1013
1015 return BaseCL::getParamAlign(ARG_SOURCE);
1016 }
1017
1019 assert(getRawSource()->getType() == Ptr->getType() &&
1020 "setSource called with pointer of wrong type!");
1021 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1022 }
1023
1025 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1026 if (Alignment)
1027 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1028 BaseCL::getContext(), *Alignment));
1029 }
1030
1031 void setSourceAlignment(Align Alignment) {
1032 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1033 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1034 BaseCL::getContext(), Alignment));
1035 }
1036};
1037
1038/// Common base class for all memset intrinsics. Simply provides
1039/// common methods.
1040template <class BaseCL> class MemSetBase : public BaseCL {
1041private:
1042 enum { ARG_VALUE = 1 };
1043
1044public:
1045 Value *getValue() const {
1046 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1047 }
1048 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1049 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1050
1051 void setValue(Value *Val) {
1052 assert(getValue()->getType() == Val->getType() &&
1053 "setValue called with value of wrong type!");
1054 BaseCL::setArgOperand(ARG_VALUE, Val);
1055 }
1056};
1057
1058// The common base class for the atomic memset/memmove/memcpy intrinsics
1059// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1060class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
1061private:
1062 enum { ARG_ELEMENTSIZE = 3 };
1063
1064public:
1066 return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
1067 }
1068
1070 return cast<ConstantInt>(getRawElementSizeInBytes());
1071 }
1072
1075 }
1076
1078 assert(V->getType() == Type::getInt8Ty(getContext()) &&
1079 "setElementSizeInBytes called with value of wrong type!");
1080 setArgOperand(ARG_ELEMENTSIZE, V);
1081 }
1082
1083 static bool classof(const IntrinsicInst *I) {
1084 switch (I->getIntrinsicID()) {
1085 case Intrinsic::memcpy_element_unordered_atomic:
1086 case Intrinsic::memmove_element_unordered_atomic:
1087 case Intrinsic::memset_element_unordered_atomic:
1088 return true;
1089 default:
1090 return false;
1091 }
1092 }
1093 static bool classof(const Value *V) {
1094 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1095 }
1096};
1097
1098/// This class represents atomic memset intrinsic
1099// i.e. llvm.element.unordered.atomic.memset
1100class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
1101public:
1102 static bool classof(const IntrinsicInst *I) {
1103 return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
1104 }
1105 static bool classof(const Value *V) {
1106 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1107 }
1108};
1109
1110// This class wraps the atomic memcpy/memmove intrinsics
1111// i.e. llvm.element.unordered.atomic.memcpy/memmove
1112class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
1113public:
1114 static bool classof(const IntrinsicInst *I) {
1115 switch (I->getIntrinsicID()) {
1116 case Intrinsic::memcpy_element_unordered_atomic:
1117 case Intrinsic::memmove_element_unordered_atomic:
1118 return true;
1119 default:
1120 return false;
1121 }
1122 }
1123 static bool classof(const Value *V) {
1124 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1125 }
1126};
1127
1128/// This class represents the atomic memcpy intrinsic
1129/// i.e. llvm.element.unordered.atomic.memcpy
1131public:
1132 static bool classof(const IntrinsicInst *I) {
1133 return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
1134 }
1135 static bool classof(const Value *V) {
1136 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1137 }
1138};
1139
1140/// This class represents the atomic memmove intrinsic
1141/// i.e. llvm.element.unordered.atomic.memmove
1143public:
1144 static bool classof(const IntrinsicInst *I) {
1145 return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
1146 }
1147 static bool classof(const Value *V) {
1148 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1149 }
1150};
1151
1152/// This is the common base class for memset/memcpy/memmove.
1153class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1154private:
1155 enum { ARG_VOLATILE = 3 };
1156
1157public:
1159 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
1160 }
1161
1162 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1163
1164 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1165
1166 // Methods for support type inquiry through isa, cast, and dyn_cast:
1167 static bool classof(const IntrinsicInst *I) {
1168 switch (I->getIntrinsicID()) {
1169 case Intrinsic::memcpy:
1170 case Intrinsic::memmove:
1171 case Intrinsic::memset:
1172 case Intrinsic::memset_inline:
1173 case Intrinsic::memcpy_inline:
1174 return true;
1175 default:
1176 return false;
1177 }
1178 }
1179 static bool classof(const Value *V) {
1180 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1181 }
1182};
1183
1184/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1185class MemSetInst : public MemSetBase<MemIntrinsic> {
1186public:
1187 // Methods for support type inquiry through isa, cast, and dyn_cast:
1188 static bool classof(const IntrinsicInst *I) {
1189 switch (I->getIntrinsicID()) {
1190 case Intrinsic::memset:
1191 case Intrinsic::memset_inline:
1192 return true;
1193 default:
1194 return false;
1195 }
1196 }
1197 static bool classof(const Value *V) {
1198 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1199 }
1200};
1201
1202/// This class wraps the llvm.memset.inline intrinsic.
1204public:
1206 return cast<ConstantInt>(MemSetInst::getLength());
1207 }
1208 // Methods for support type inquiry through isa, cast, and dyn_cast:
1209 static bool classof(const IntrinsicInst *I) {
1210 return I->getIntrinsicID() == Intrinsic::memset_inline;
1211 }
1212 static bool classof(const Value *V) {
1213 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1214 }
1215};
1216
1217/// This class wraps the llvm.memcpy/memmove intrinsics.
1218class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1219public:
1220 // Methods for support type inquiry through isa, cast, and dyn_cast:
1221 static bool classof(const IntrinsicInst *I) {
1222 switch (I->getIntrinsicID()) {
1223 case Intrinsic::memcpy:
1224 case Intrinsic::memmove:
1225 case Intrinsic::memcpy_inline:
1226 return true;
1227 default:
1228 return false;
1229 }
1230 }
1231 static bool classof(const Value *V) {
1232 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1233 }
1234};
1235
1236/// This class wraps the llvm.memcpy intrinsic.
1238public:
1239 // Methods for support type inquiry through isa, cast, and dyn_cast:
1240 static bool classof(const IntrinsicInst *I) {
1241 return I->getIntrinsicID() == Intrinsic::memcpy ||
1242 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1243 }
1244 static bool classof(const Value *V) {
1245 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1246 }
1247};
1248
1249/// This class wraps the llvm.memmove intrinsic.
1251public:
1252 // Methods for support type inquiry through isa, cast, and dyn_cast:
1253 static bool classof(const IntrinsicInst *I) {
1254 return I->getIntrinsicID() == Intrinsic::memmove;
1255 }
1256 static bool classof(const Value *V) {
1257 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1258 }
1259};
1260
1261/// This class wraps the llvm.memcpy.inline intrinsic.
1263public:
1265 return cast<ConstantInt>(MemCpyInst::getLength());
1266 }
1267 // Methods for support type inquiry through isa, cast, and dyn_cast:
1268 static bool classof(const IntrinsicInst *I) {
1269 return I->getIntrinsicID() == Intrinsic::memcpy_inline;
1270 }
1271 static bool classof(const Value *V) {
1272 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1273 }
1274};
1275
1276// The common base class for any memset/memmove/memcpy intrinsics;
1277// whether they be atomic or non-atomic.
1278// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1279// and llvm.memset/memcpy/memmove
1280class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1281public:
1282 bool isVolatile() const {
1283 // Only the non-atomic intrinsics can be volatile
1284 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1285 return MI->isVolatile();
1286 return false;
1287 }
1288
1289 static bool classof(const IntrinsicInst *I) {
1290 switch (I->getIntrinsicID()) {
1291 case Intrinsic::memcpy:
1292 case Intrinsic::memcpy_inline:
1293 case Intrinsic::memmove:
1294 case Intrinsic::memset:
1295 case Intrinsic::memset_inline:
1296 case Intrinsic::memcpy_element_unordered_atomic:
1297 case Intrinsic::memmove_element_unordered_atomic:
1298 case Intrinsic::memset_element_unordered_atomic:
1299 return true;
1300 default:
1301 return false;
1302 }
1303 }
1304 static bool classof(const Value *V) {
1305 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1306 }
1307};
1308
1309/// This class represents any memset intrinsic
1310// i.e. llvm.element.unordered.atomic.memset
1311// and llvm.memset
1312class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1313public:
1314 static bool classof(const IntrinsicInst *I) {
1315 switch (I->getIntrinsicID()) {
1316 case Intrinsic::memset:
1317 case Intrinsic::memset_inline:
1318 case Intrinsic::memset_element_unordered_atomic:
1319 return true;
1320 default:
1321 return false;
1322 }
1323 }
1324 static bool classof(const Value *V) {
1325 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1326 }
1327};
1328
1329// This class wraps any memcpy/memmove intrinsics
1330// i.e. llvm.element.unordered.atomic.memcpy/memmove
1331// and llvm.memcpy/memmove
1332class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1333public:
1334 static bool classof(const IntrinsicInst *I) {
1335 switch (I->getIntrinsicID()) {
1336 case Intrinsic::memcpy:
1337 case Intrinsic::memcpy_inline:
1338 case Intrinsic::memmove:
1339 case Intrinsic::memcpy_element_unordered_atomic:
1340 case Intrinsic::memmove_element_unordered_atomic:
1341 return true;
1342 default:
1343 return false;
1344 }
1345 }
1346 static bool classof(const Value *V) {
1347 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1348 }
1349};
1350
1351/// This class represents any memcpy intrinsic
1352/// i.e. llvm.element.unordered.atomic.memcpy
1353/// and llvm.memcpy
1355public:
1356 static bool classof(const IntrinsicInst *I) {
1357 switch (I->getIntrinsicID()) {
1358 case Intrinsic::memcpy:
1359 case Intrinsic::memcpy_inline:
1360 case Intrinsic::memcpy_element_unordered_atomic:
1361 return true;
1362 default:
1363 return false;
1364 }
1365 }
1366 static bool classof(const Value *V) {
1367 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1368 }
1369};
1370
1371/// This class represents any memmove intrinsic
1372/// i.e. llvm.element.unordered.atomic.memmove
1373/// and llvm.memmove
1375public:
1376 static bool classof(const IntrinsicInst *I) {
1377 switch (I->getIntrinsicID()) {
1378 case Intrinsic::memmove:
1379 case Intrinsic::memmove_element_unordered_atomic:
1380 return true;
1381 default:
1382 return false;
1383 }
1384 }
1385 static bool classof(const Value *V) {
1386 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1387 }
1388};
1389
1390/// This represents the llvm.va_start intrinsic.
1392public:
1393 static bool classof(const IntrinsicInst *I) {
1394 return I->getIntrinsicID() == Intrinsic::vastart;
1395 }
1396 static bool classof(const Value *V) {
1397 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1398 }
1399
1400 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1401};
1402
1403/// This represents the llvm.va_end intrinsic.
1404class VAEndInst : public IntrinsicInst {
1405public:
1406 static bool classof(const IntrinsicInst *I) {
1407 return I->getIntrinsicID() == Intrinsic::vaend;
1408 }
1409 static bool classof(const Value *V) {
1410 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1411 }
1412
1413 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1414};
1415
1416/// This represents the llvm.va_copy intrinsic.
1418public:
1419 static bool classof(const IntrinsicInst *I) {
1420 return I->getIntrinsicID() == Intrinsic::vacopy;
1421 }
1422 static bool classof(const Value *V) {
1423 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1424 }
1425
1426 Value *getDest() const { return const_cast<Value *>(getArgOperand(0)); }
1427 Value *getSrc() const { return const_cast<Value *>(getArgOperand(1)); }
1428};
1429
1430/// A base class for all instrprof intrinsics.
1432public:
1433 // The name of the instrumented function.
1435 return cast<GlobalVariable>(
1436 const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
1437 }
1438 // The hash of the CFG for the instrumented function.
1440 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1441 }
1442};
1443
1444/// A base class for all instrprof counter intrinsics.
1446public:
1447 // The number of counters for the instrumented function.
1448 ConstantInt *getNumCounters() const;
1449 // The index of the counter that this instruction acts on.
1450 ConstantInt *getIndex() const;
1451};
1452
1453/// This represents the llvm.instrprof.cover intrinsic.
1455public:
1456 static bool classof(const IntrinsicInst *I) {
1457 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1458 }
1459 static bool classof(const Value *V) {
1460 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1461 }
1462};
1463
1464/// This represents the llvm.instrprof.increment intrinsic.
1466public:
1467 static bool classof(const IntrinsicInst *I) {
1468 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1469 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1470 }
1471 static bool classof(const Value *V) {
1472 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1473 }
1474 Value *getStep() const;
1475};
1476
1477/// This represents the llvm.instrprof.increment.step intrinsic.
1479public:
1480 static bool classof(const IntrinsicInst *I) {
1481 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
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.timestamp intrinsic.
1490public:
1491 static bool classof(const IntrinsicInst *I) {
1492 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1493 }
1494 static bool classof(const Value *V) {
1495 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1496 }
1497};
1498
1499/// This represents the llvm.instrprof.value.profile intrinsic.
1501public:
1502 static bool classof(const IntrinsicInst *I) {
1503 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1504 }
1505 static bool classof(const Value *V) {
1506 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1507 }
1508
1510 return cast<Value>(const_cast<Value *>(getArgOperand(2)));
1511 }
1512
1514 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1515 }
1516
1517 // Returns the value site index.
1519 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
1520 }
1521};
1522
1523/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1525public:
1526 static bool classof(const IntrinsicInst *I) {
1527 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters ||
1528 I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1529 }
1530 static bool classof(const Value *V) {
1531 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1532 }
1533
1534 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1535 /// function.
1537 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1538 }
1539};
1540
1541/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1543public:
1544 static bool classof(const IntrinsicInst *I) {
1545 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1546 }
1547 static bool classof(const Value *V) {
1548 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1549 }
1550};
1551
1552/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1554public:
1555 static bool classof(const IntrinsicInst *I) {
1556 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1557 }
1558 static bool classof(const Value *V) {
1559 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1560 }
1561
1562 /// \return The index of the TestVector Bitmap upon which this intrinsic
1563 /// acts.
1565 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1566 }
1567
1568 /// \return The address of the corresponding condition bitmap containing
1569 /// the index of the TestVector to update within the TestVector Bitmap.
1571 return cast<Value>(const_cast<Value *>(getArgOperand(4)));
1572 }
1573};
1574
1575/// This represents the llvm.instrprof.mcdc.condbitmap.update intrinsic.
1576/// It does not pertain to global bitmap updates or parameters and so doesn't
1577/// inherit from InstrProfMCDCBitmapInstBase.
1579public:
1580 static bool classof(const IntrinsicInst *I) {
1581 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_condbitmap_update;
1582 }
1583 static bool classof(const Value *V) {
1584 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1585 }
1586
1587 /// \return The ID of the condition to update.
1589 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1590 }
1591
1592 /// \return The address of the corresponding condition bitmap.
1594 return cast<Value>(const_cast<Value *>(getArgOperand(3)));
1595 }
1596
1597 /// \return The boolean value to set in the condition bitmap for the
1598 /// corresponding condition ID. This represents how the condition evaluated.
1600 return cast<Value>(const_cast<Value *>(getArgOperand(4)));
1601 }
1602};
1603
1605public:
1606 static bool classof(const IntrinsicInst *I) {
1607 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1608 }
1609
1610 static bool classof(const Value *V) {
1611 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1612 }
1613
1615 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(0)));
1616 }
1617
1619 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1620 }
1621
1623 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1624 }
1625
1627 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1628 }
1629};
1630
1632public:
1633 static bool classof(const IntrinsicInst *I) {
1634 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1635 }
1636
1637 static bool classof(const Value *V) {
1638 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1639 }
1640
1642 auto *MV =
1643 cast<MetadataAsValue>(getOperand(Intrinsic::NoAliasScopeDeclScopeArg));
1644 return cast<MDNode>(MV->getMetadata());
1645 }
1646
1647 void setScopeList(MDNode *ScopeList) {
1649 MetadataAsValue::get(getContext(), ScopeList));
1650 }
1651};
1652
1653/// Common base class for representing values projected from a statepoint.
1654/// Currently, the only projections available are gc.result and gc.relocate.
1656public:
1657 static bool classof(const IntrinsicInst *I) {
1658 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1659 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1660 }
1661
1662 static bool classof(const Value *V) {
1663 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1664 }
1665
1666 /// Return true if this relocate is tied to the invoke statepoint.
1667 /// This includes relocates which are on the unwinding path.
1668 bool isTiedToInvoke() const {
1669 const Value *Token = getArgOperand(0);
1670
1671 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1672 }
1673
1674 /// The statepoint with which this gc.relocate is associated.
1675 const Value *getStatepoint() const;
1676};
1677
1678/// Represents calls to the gc.relocate intrinsic.
1680public:
1681 static bool classof(const IntrinsicInst *I) {
1682 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1683 }
1684
1685 static bool classof(const Value *V) {
1686 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1687 }
1688
1689 /// The index into the associate statepoint's argument list
1690 /// which contains the base pointer of the pointer whose
1691 /// relocation this gc.relocate describes.
1692 unsigned getBasePtrIndex() const {
1693 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1694 }
1695
1696 /// The index into the associate statepoint's argument list which
1697 /// contains the pointer whose relocation this gc.relocate describes.
1698 unsigned getDerivedPtrIndex() const {
1699 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1700 }
1701
1702 Value *getBasePtr() const;
1703 Value *getDerivedPtr() const;
1704};
1705
1706/// Represents calls to the gc.result intrinsic.
1708public:
1709 static bool classof(const IntrinsicInst *I) {
1710 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1711 }
1712
1713 static bool classof(const Value *V) {
1714 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1715 }
1716};
1717
1718
1719/// This represents the llvm.assume intrinsic.
1721public:
1722 static bool classof(const IntrinsicInst *I) {
1723 return I->getIntrinsicID() == Intrinsic::assume;
1724 }
1725 static bool classof(const Value *V) {
1726 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1727 }
1728};
1729
1730/// Check if \p ID corresponds to a convergence control intrinsic.
1731static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1732 switch (IntrinsicID) {
1733 default:
1734 return false;
1735 case Intrinsic::experimental_convergence_anchor:
1736 case Intrinsic::experimental_convergence_entry:
1737 case Intrinsic::experimental_convergence_loop:
1738 return true;
1739 }
1740}
1741
1742/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1744public:
1745 static bool classof(const IntrinsicInst *I) {
1746 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1747 }
1748
1749 static bool classof(const Value *V) {
1750 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1751 }
1752};
1753
1754} // end namespace llvm
1755
1756#endif // LLVM_IR_INTRINSICINST_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DEPRECATED(MSG, FIX)
Definition: Compiler.h:157
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 I(x, y, z)
Definition: MD5.cpp:58
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static SymbolRef::Type getType(const Symbol *Sym)
Definition: TapiFile.cpp:40
Value * RHS
Class for arbitrary precision integers.
Definition: APInt.h:76
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
Definition: APInt.h:184
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
Definition: APInt.h:187
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
Definition: APInt.h:194
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Definition: APInt.h:197
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)
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)
This class represents the atomic memcpy intrinsic i.e.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getElementSizeInBytesCst() const
static bool classof(const IntrinsicInst *I)
Value * getRawElementSizeInBytes() const
static bool classof(const Value *V)
void setElementSizeInBytes(Constant *V)
uint32_t getElementSizeInBytes() const
This class represents the atomic memmove intrinsic i.e.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This class represents atomic 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)
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:168
This class represents an intrinsic that is based on a binary operation.
Value * getRHS() const
static bool classof(const Value *V)
unsigned getNoWrapKind() const
Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
bool isSigned() const
Whether the intrinsic is signed or unsigned.
static bool classof(const IntrinsicInst *I)
Instruction::BinaryOps getBinaryOp() const
Returns the binary operation underlying the intrinsic.
Value * getLHS() const
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Definition: InstrTypes.h:1872
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1696
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: InstrTypes.h:2046
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Definition: InstrTypes.h:1652
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1641
void setArgOperand(unsigned i, Value *v)
Definition: InstrTypes.h:1646
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1825
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:967
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:996
@ ICMP_UGT
unsigned greater than
Definition: InstrTypes.h:990
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:994
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:992
bool isSigned() const
Definition: InstrTypes.h:1228
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Definition: Constants.h:204
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:153
This is an important base class in LLVM.
Definition: Constant.h:41
static 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:400
Constrained floating point compare intrinsics.
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.
std::optional< fp::ExceptionBehavior > getExceptionBehavior() const
std::optional< RoundingMode > getRoundingMode() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Represents calls to the llvm.experimintal.convergence.* intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Assignment ID.
DWARF expression.
static 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
static bool classof(const Value *V)
void setAssignId(DIAssignID *New)
void setKillAddress()
Kill the address component.
bool isKillAddress() const
Check whether this kills the address component.
Metadata * getRawAddress() const
DIExpression * getAddressExpression() const
Value * getAddress() const
static bool classof(const IntrinsicInst *I)
Metadata * getRawAddressExpression() const
Metadata * getRawAssignID() const
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)
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
void replaceVariableLocationOp(Value *OldValue, Value *NewValue)
void setRawLocation(Metadata *Location)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
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)
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.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:230
Common base class for representing values projected from a statepoint.
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)
Value * getBasePtr() const
unsigned getBasePtrIndex() const
The index into the associate statepoint's argument list which contains the base pointer of the pointe...
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)
A base class for all instrprof counter intrinsics.
ConstantInt * getIndex() const
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)
A base class for all instrprof intrinsics.
GlobalVariable * getName() const
ConstantInt * getHash() const
A base class for instrprof mcdc intrinsics that require global bitmap bytes.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getNumBitmapBytes() const
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.condbitmap.update 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:47
bool isAssumeLikeIntrinsic() const
Checks if the intrinsic is an annotation.
static 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:54
bool isCommutative() const
Return true if swapping the first two arguments to the intrinsic produces the same result.
Definition: IntrinsicInst.h:72
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:58
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:1067
LLVMContext & getContext() const
Definition: Metadata.h:1231
This class wraps the llvm.memcpy.inline intrinsic.
static bool classof(const IntrinsicInst *I)
ConstantInt * getLength() const
static bool classof(const Value *V)
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 setDest(Value *Ptr)
Set the specified arguments of the instruction.
unsigned getDestAlignment() const
FIXME: Remove this function once transition to Align is over.
MaybeAlign getDestAlign() const
const Use & getLengthUse() const
unsigned getDestAddressSpace() const
This is the common base class for memset/memcpy/memmove.
ConstantInt * getVolatileCst() const
void setVolatile(Constant *V)
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.inline intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getLength() const
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memory transfer intrinsics.
unsigned getSourceAlignment() const
FIXME: Remove this function once transition to Align is over.
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 MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:103
Root of the metadata hierarchy.
Definition: Metadata.h:62
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:65
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 PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1827
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)
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
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:342
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:427
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static IntegerType * getInt8Ty(LLVMContext &C)
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
Value * getOperand(unsigned i) const
Definition: User.h:169
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 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 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 bool isVPCmp(Intrinsic::ID ID)
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 Function * getDeclarationForParams(Module *M, Intrinsic::ID, Type *ReturnType, ArrayRef< Value * > Params)
Declares a llvm.vp.
static std::optional< unsigned > getMaskParamPos(Intrinsic::ID IntrinsicID)
bool canIgnoreVectorLengthParam() const
void setMaskParam(Value *)
static std::optional< unsigned > getFunctionalOpcodeForVP(Intrinsic::ID ID)
static std::optional< unsigned > getMemoryDataParamPos(Intrinsic::ID)
Value * getVectorLengthParam() const
static bool classof(const IntrinsicInst *I)
static std::optional< Intrinsic::ID > getFunctionalIntrinsicIDForVP(Intrinsic::ID ID)
void setVectorLengthParam(Value *)
static std::optional< unsigned > getVectorLengthParamPos(Intrinsic::ID IntrinsicID)
static Intrinsic::ID getForOpcode(unsigned OC)
The llvm.vp.* intrinsics for this instruction Opcode.
static std::optional< unsigned > getMemoryPointerParamPos(Intrinsic::ID)
static bool isVPIntrinsic(Intrinsic::ID)
Value * getMemoryDataParam() const
Value * getMemoryPointerParam() const
std::optional< unsigned > getConstrainedIntrinsicID() const
MaybeAlign getPointerAlignment() const
Value * getMaskParam() const
ElementCount getStaticVectorLength() const
static 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 bool isVPReduction(Intrinsic::ID ID)
unsigned getStartParamPos() const
unsigned getVectorParamPos() const
Value wrapper in the Metadata hierarchy.
Definition: Metadata.h:450
Value * getValue() const
Definition: Metadata.h:490
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:693
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1074
Represents an op.with.overflow intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:80
A range adaptor for a pair of iterators.
bool operator==(const location_op_iterator &RHS) const
location_op_iterator & operator=(const location_op_iterator &R)
location_op_iterator(ValueAsMetadata **MultiIter)
location_op_iterator(const location_op_iterator &R)
location_op_iterator & operator++()
location_op_iterator(ValueAsMetadata *SingleIter)
location_op_iterator & operator--()
const Value * operator*() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const int NoAliasScopeDeclScopeArg
Definition: Intrinsics.h:37
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:1738
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.
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
Holds the characteristics of one fragment of a larger variable.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117