LLVM 17.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 /// Return true if swapping the first two arguments to the intrinsic produces
59 /// the same result.
60 bool isCommutative() const {
61 switch (getIntrinsicID()) {
62 case Intrinsic::maxnum:
63 case Intrinsic::minnum:
64 case Intrinsic::maximum:
65 case Intrinsic::minimum:
66 case Intrinsic::smax:
67 case Intrinsic::smin:
68 case Intrinsic::umax:
69 case Intrinsic::umin:
70 case Intrinsic::sadd_sat:
71 case Intrinsic::uadd_sat:
72 case Intrinsic::sadd_with_overflow:
73 case Intrinsic::uadd_with_overflow:
74 case Intrinsic::smul_with_overflow:
75 case Intrinsic::umul_with_overflow:
76 case Intrinsic::smul_fix:
77 case Intrinsic::umul_fix:
78 case Intrinsic::smul_fix_sat:
79 case Intrinsic::umul_fix_sat:
80 case Intrinsic::fma:
81 case Intrinsic::fmuladd:
82 return true;
83 default:
84 return false;
85 }
86 }
87
88 /// Checks if the intrinsic is an annotation.
89 bool isAssumeLikeIntrinsic() const {
90 switch (getIntrinsicID()) {
91 default: break;
92 case Intrinsic::assume:
93 case Intrinsic::sideeffect:
94 case Intrinsic::pseudoprobe:
95 case Intrinsic::dbg_assign:
96 case Intrinsic::dbg_declare:
97 case Intrinsic::dbg_value:
98 case Intrinsic::dbg_label:
99 case Intrinsic::invariant_start:
100 case Intrinsic::invariant_end:
101 case Intrinsic::lifetime_start:
102 case Intrinsic::lifetime_end:
103 case Intrinsic::experimental_noalias_scope_decl:
104 case Intrinsic::objectsize:
105 case Intrinsic::ptr_annotation:
106 case Intrinsic::var_annotation:
107 return true;
108 }
109 return false;
110 }
111
112 /// Check if the intrinsic might lower into a regular function call in the
113 /// course of IR transformations
114 static bool mayLowerToFunctionCall(Intrinsic::ID IID);
115
116 /// Methods for support type inquiry through isa, cast, and dyn_cast:
117 static bool classof(const CallInst *I) {
118 if (const Function *CF = I->getCalledFunction())
119 return CF->isIntrinsic();
120 return false;
121 }
122 static bool classof(const Value *V) {
123 return isa<CallInst>(V) && classof(cast<CallInst>(V));
124 }
125};
126
127/// Check if \p ID corresponds to a lifetime intrinsic.
129 switch (ID) {
130 case Intrinsic::lifetime_start:
131 case Intrinsic::lifetime_end:
132 return true;
133 default:
134 return false;
135 }
136}
137
138/// This is the common base class for lifetime intrinsics.
140public:
141 /// \name Casting methods
142 /// @{
143 static bool classof(const IntrinsicInst *I) {
144 return isLifetimeIntrinsic(I->getIntrinsicID());
145 }
146 static bool classof(const Value *V) {
147 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
148 }
149 /// @}
150};
151
152/// Check if \p ID corresponds to a debug info intrinsic.
154 switch (ID) {
155 case Intrinsic::dbg_declare:
156 case Intrinsic::dbg_value:
157 case Intrinsic::dbg_label:
158 case Intrinsic::dbg_assign:
159 return true;
160 default:
161 return false;
162 }
163}
164
165/// This is the common base class for debug info intrinsics.
167public:
168 /// \name Casting methods
169 /// @{
170 static bool classof(const IntrinsicInst *I) {
171 return isDbgInfoIntrinsic(I->getIntrinsicID());
172 }
173 static bool classof(const Value *V) {
174 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
175 }
176 /// @}
177};
178
179// Iterator for ValueAsMetadata that internally uses direct pointer iteration
180// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
181// ValueAsMetadata .
183 : public iterator_facade_base<location_op_iterator,
184 std::bidirectional_iterator_tag, Value *> {
186
187public:
188 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
189 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
190
193 I = R.I;
194 return *this;
195 }
196 bool operator==(const location_op_iterator &RHS) const { return I == RHS.I; }
197 const Value *operator*() const {
198 ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
199 ? cast<ValueAsMetadata *>(I)
200 : *cast<ValueAsMetadata **>(I);
201 return VAM->getValue();
202 };
204 ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
205 ? cast<ValueAsMetadata *>(I)
206 : *cast<ValueAsMetadata **>(I);
207 return VAM->getValue();
208 }
210 if (isa<ValueAsMetadata *>(I))
211 I = cast<ValueAsMetadata *>(I) + 1;
212 else
213 I = cast<ValueAsMetadata **>(I) + 1;
214 return *this;
215 }
217 if (isa<ValueAsMetadata *>(I))
218 I = cast<ValueAsMetadata *>(I) - 1;
219 else
220 I = cast<ValueAsMetadata **>(I) - 1;
221 return *this;
222 }
223};
224
225/// Lightweight class that wraps the location operand metadata of a debug
226/// intrinsic. The raw location may be a ValueAsMetadata, an empty MDTuple,
227/// or a DIArgList.
229 Metadata *RawLocation = nullptr;
230
231public:
233 explicit RawLocationWrapper(Metadata *RawLocation)
234 : RawLocation(RawLocation) {
235 // Allow ValueAsMetadata, empty MDTuple, DIArgList.
236 assert(RawLocation && "unexpected null RawLocation");
237 assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
238 (isa<MDNode>(RawLocation) &&
239 !cast<MDNode>(RawLocation)->getNumOperands()));
240 }
241 Metadata *getRawLocation() const { return RawLocation; }
242 /// Get the locations corresponding to the variable referenced by the debug
243 /// info intrinsic. Depending on the intrinsic, this could be the
244 /// variable's value or its address.
246 Value *getVariableLocationOp(unsigned OpIdx) const;
247 unsigned getNumVariableLocationOps() const {
248 if (hasArgList())
249 return cast<DIArgList>(getRawLocation())->getArgs().size();
250 return 1;
251 }
252 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
254 // Check for "kill" sentinel values.
255 // Non-variadic: empty metadata.
256 if (!hasArgList() && isa<MDNode>(getRawLocation()))
257 return true;
258 // Variadic: empty DIArgList with empty expression.
259 if (getNumVariableLocationOps() == 0 && !Expression->isComplex())
260 return true;
261 // Variadic and non-variadic: Interpret expressions using undef or poison
262 // values as kills.
263 return any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
264 }
265
266 friend bool operator==(const RawLocationWrapper &A,
267 const RawLocationWrapper &B) {
268 return A.RawLocation == B.RawLocation;
269 }
270 friend bool operator!=(const RawLocationWrapper &A,
271 const RawLocationWrapper &B) {
272 return !(A == B);
273 }
274 friend bool operator>(const RawLocationWrapper &A,
275 const RawLocationWrapper &B) {
276 return A.RawLocation > B.RawLocation;
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.RawLocation < B.RawLocation;
285 }
286 friend bool operator<=(const RawLocationWrapper &A,
287 const RawLocationWrapper &B) {
288 return A.RawLocation <= B.RawLocation;
289 }
290};
291
292/// This is the common base class for debug info intrinsics for variables.
294public:
295 /// Get the locations corresponding to the variable referenced by the debug
296 /// info intrinsic. Depending on the intrinsic, this could be the
297 /// variable's value or its address.
299
300 Value *getVariableLocationOp(unsigned OpIdx) const;
301
302 void replaceVariableLocationOp(Value *OldValue, Value *NewValue);
303 void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
304 /// Adding a new location operand will always result in this intrinsic using
305 /// an ArgList, and must always be accompanied by a new expression that uses
306 /// the new operand.
309
311 setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
312 }
313
316 }
317
318 unsigned getNumVariableLocationOps() const {
320 }
321
322 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
323
324 /// Does this describe the address of a local variable. True for dbg.declare,
325 /// but not dbg.value, which describes its value, or dbg.assign, which
326 /// describes a combination of the variable's value and address.
327 bool isAddressOfVariable() const {
328 return getIntrinsicID() == Intrinsic::dbg_declare;
329 }
330
332 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
333 // this set anymore.
334 SmallPtrSet<Value *, 4> RemovedValues;
335 for (Value *OldValue : location_ops()) {
336 if (!RemovedValues.insert(OldValue).second)
337 continue;
338 Value *Poison = PoisonValue::get(OldValue->getType());
339 replaceVariableLocationOp(OldValue, Poison);
340 }
341 }
342
343 bool isKillLocation() const {
345 }
346
348 return cast<DILocalVariable>(getRawVariable());
349 }
350
352 return cast<DIExpression>(getRawExpression());
353 }
354
356 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
357 }
358
361 }
362
364 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
365 }
366
368 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
369 }
370
371 /// Use of this should generally be avoided; instead,
372 /// replaceVariableLocationOp and addVariableLocationOps should be used where
373 /// possible to avoid creating invalid state.
374 void setRawLocation(Metadata *Location) {
375 return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
376 }
377
378 /// Get the size (in bits) of the variable, or fragment of the variable that
379 /// is described.
380 std::optional<uint64_t> getFragmentSizeInBits() const;
381
382 /// Get the FragmentInfo for the variable.
383 std::optional<DIExpression::FragmentInfo> getFragment() const {
384 return getExpression()->getFragmentInfo();
385 }
386
387 /// Get the FragmentInfo for the variable if it exists, otherwise return a
388 /// FragmentInfo that covers the entire variable if the variable size is
389 /// known, otherwise return a zero-sized fragment.
391 DIExpression::FragmentInfo VariableSlice(0, 0);
392 // Get the fragment or variable size, or zero.
393 if (auto Sz = getFragmentSizeInBits())
394 VariableSlice.SizeInBits = *Sz;
395 if (auto Frag = getExpression()->getFragmentInfo())
396 VariableSlice.OffsetInBits = Frag->OffsetInBits;
397 return VariableSlice;
398 }
399
400 /// \name Casting methods
401 /// @{
402 static bool classof(const IntrinsicInst *I) {
403 switch (I->getIntrinsicID()) {
404 case Intrinsic::dbg_declare:
405 case Intrinsic::dbg_value:
406 case Intrinsic::dbg_assign:
407 return true;
408 default:
409 return false;
410 }
411 }
412 static bool classof(const Value *V) {
413 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
414 }
415 /// @}
416protected:
417 void setArgOperand(unsigned i, Value *v) {
419 }
420 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
421};
422
423/// This represents the llvm.dbg.declare instruction.
425public:
426 Value *getAddress() const {
428 "dbg.declare must have exactly 1 location operand.");
429 return getVariableLocationOp(0);
430 }
431
432 /// \name Casting methods
433 /// @{
434 static bool classof(const IntrinsicInst *I) {
435 return I->getIntrinsicID() == Intrinsic::dbg_declare;
436 }
437 static bool classof(const Value *V) {
438 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
439 }
440 /// @}
441};
442
443/// This represents the llvm.dbg.value instruction.
445public:
446 // The default argument should only be used in ISel, and the default option
447 // should be removed once ISel support for multiple location ops is complete.
448 Value *getValue(unsigned OpIdx = 0) const {
449 return getVariableLocationOp(OpIdx);
450 }
452 return location_ops();
453 }
454
455 /// \name Casting methods
456 /// @{
457 static bool classof(const IntrinsicInst *I) {
458 return I->getIntrinsicID() == Intrinsic::dbg_value ||
459 I->getIntrinsicID() == Intrinsic::dbg_assign;
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.assign instruction.
469 enum Operands {
470 OpValue,
471 OpVar,
472 OpExpr,
473 OpAssignID,
474 OpAddress,
475 OpAddressExpr,
476 };
477
478public:
479 Value *getAddress() const;
481 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
482 }
484 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
485 }
486 DIAssignID *getAssignID() const { return cast<DIAssignID>(getRawAssignID()); }
488 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
489 }
491 return cast<DIExpression>(getRawAddressExpression());
492 }
494 setArgOperand(OpAddressExpr,
495 MetadataAsValue::get(NewExpr->getContext(), NewExpr));
496 }
497 void setAssignId(DIAssignID *New);
498 void setAddress(Value *V);
499 /// Kill the address component.
500 void setKillAddress();
501 /// Check whether this kills the address component. This doesn't take into
502 /// account the position of the intrinsic, therefore a returned value of false
503 /// does not guarentee the address is a valid location for the variable at the
504 /// intrinsic's position in IR.
505 bool isKillAddress() const;
506 void setValue(Value *V);
507 /// \name Casting methods
508 /// @{
509 static bool classof(const IntrinsicInst *I) {
510 return I->getIntrinsicID() == Intrinsic::dbg_assign;
511 }
512 static bool classof(const Value *V) {
513 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
514 }
515 /// @}
516};
517
518/// This represents the llvm.dbg.label instruction.
520public:
521 DILabel *getLabel() const { return cast<DILabel>(getRawLabel()); }
522
524 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
525 }
526
527 /// Methods for support type inquiry through isa, cast, and dyn_cast:
528 /// @{
529 static bool classof(const IntrinsicInst *I) {
530 return I->getIntrinsicID() == Intrinsic::dbg_label;
531 }
532 static bool classof(const Value *V) {
533 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
534 }
535 /// @}
536};
537
538/// This is the common base class for vector predication intrinsics.
540public:
541 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
542 /// \p Params. Additionally, the load and gather intrinsics require
543 /// \p ReturnType to be specified.
545 Type *ReturnType,
546 ArrayRef<Value *> Params);
547
548 static std::optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
549 static std::optional<unsigned> getVectorLengthParamPos(
550 Intrinsic::ID IntrinsicID);
551
552 /// The llvm.vp.* intrinsics for this instruction Opcode
553 static Intrinsic::ID getForOpcode(unsigned OC);
554
555 // Whether \p ID is a VP intrinsic ID.
556 static bool isVPIntrinsic(Intrinsic::ID);
557
558 /// \return The mask parameter or nullptr.
559 Value *getMaskParam() const;
560 void setMaskParam(Value *);
561
562 /// \return The vector length parameter or nullptr.
565
566 /// \return Whether the vector length param can be ignored.
567 bool canIgnoreVectorLengthParam() const;
568
569 /// \return The static element count (vector number of elements) the vector
570 /// length parameter applies to.
572
573 /// \return The alignment of the pointer used by this load/store/gather or
574 /// scatter.
576 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
577
578 /// \return The pointer operand of this load,store, gather or scatter.
580 static std::optional<unsigned> getMemoryPointerParamPos(Intrinsic::ID);
581
582 /// \return The data (payload) operand of this store or scatter.
583 Value *getMemoryDataParam() const;
584 static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
585
586 // Methods for support type inquiry through isa, cast, and dyn_cast:
587 static bool classof(const IntrinsicInst *I) {
588 return isVPIntrinsic(I->getIntrinsicID());
589 }
590 static bool classof(const Value *V) {
591 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
592 }
593
594 // Equivalent non-predicated opcode
595 std::optional<unsigned> getFunctionalOpcode() const {
597 }
598
599 // Equivalent non-predicated constrained ID
600 std::optional<unsigned> getConstrainedIntrinsicID() const {
602 }
603
604 // Equivalent non-predicated opcode
605 static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
606
607 // Equivalent non-predicated constrained ID
608 static std::optional<unsigned>
610};
611
612/// This represents vector predication reduction intrinsics.
614public:
615 static bool isVPReduction(Intrinsic::ID ID);
616
617 unsigned getStartParamPos() const;
618 unsigned getVectorParamPos() const;
619
620 static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
621 static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
622
623 /// Methods for support type inquiry through isa, cast, and dyn_cast:
624 /// @{
625 static bool classof(const IntrinsicInst *I) {
626 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
627 }
628 static bool classof(const Value *V) {
629 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
630 }
631 /// @}
632};
633
635public:
636 static bool isVPCast(Intrinsic::ID ID);
637
638 /// Methods for support type inquiry through isa, cast, and dyn_cast:
639 /// @{
640 static bool classof(const IntrinsicInst *I) {
641 return VPCastIntrinsic::isVPCast(I->getIntrinsicID());
642 }
643 static bool classof(const Value *V) {
644 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
645 }
646 /// @}
647};
648
650public:
651 static bool isVPCmp(Intrinsic::ID ID);
652
654
655 /// Methods for support type inquiry through isa, cast, and dyn_cast:
656 /// @{
657 static bool classof(const IntrinsicInst *I) {
658 return VPCmpIntrinsic::isVPCmp(I->getIntrinsicID());
659 }
660 static bool classof(const Value *V) {
661 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
662 }
663 /// @}
664};
665
666/// This is the common base class for constrained floating point intrinsics.
668public:
669 bool isUnaryOp() const;
670 bool isTernaryOp() const;
671 std::optional<RoundingMode> getRoundingMode() const;
672 std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
673 bool isDefaultFPEnvironment() const;
674
675 // Methods for support type inquiry through isa, cast, and dyn_cast:
676 static bool classof(const IntrinsicInst *I);
677 static bool classof(const Value *V) {
678 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
679 }
680};
681
682/// Constrained floating point compare intrinsics.
684public:
686 bool isSignaling() const {
687 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
688 }
689
690 // Methods for support type inquiry through isa, cast, and dyn_cast:
691 static bool classof(const IntrinsicInst *I) {
692 switch (I->getIntrinsicID()) {
693 case Intrinsic::experimental_constrained_fcmp:
694 case Intrinsic::experimental_constrained_fcmps:
695 return true;
696 default:
697 return false;
698 }
699 }
700 static bool classof(const Value *V) {
701 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
702 }
703};
704
705/// This class represents min/max intrinsics.
707public:
708 static bool classof(const IntrinsicInst *I) {
709 switch (I->getIntrinsicID()) {
710 case Intrinsic::umin:
711 case Intrinsic::umax:
712 case Intrinsic::smin:
713 case Intrinsic::smax:
714 return true;
715 default:
716 return false;
717 }
718 }
719 static bool classof(const Value *V) {
720 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
721 }
722
723 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
724 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
725
726 /// Returns the comparison predicate underlying the intrinsic.
728 switch (ID) {
729 case Intrinsic::umin:
731 case Intrinsic::umax:
733 case Intrinsic::smin:
735 case Intrinsic::smax:
737 default:
738 llvm_unreachable("Invalid intrinsic");
739 }
740 }
741
742 /// Returns the comparison predicate underlying the intrinsic.
745 }
746
747 /// Whether the intrinsic is signed or unsigned.
748 static bool isSigned(Intrinsic::ID ID) {
750 };
751
752 /// Whether the intrinsic is signed or unsigned.
753 bool isSigned() const { return isSigned(getIntrinsicID()); };
754
755 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
756 /// so there is a certain threshold value, upon reaching which,
757 /// their value can no longer change. Return said threshold.
758 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
759 switch (ID) {
760 case Intrinsic::umin:
761 return APInt::getMinValue(numBits);
762 case Intrinsic::umax:
763 return APInt::getMaxValue(numBits);
764 case Intrinsic::smin:
765 return APInt::getSignedMinValue(numBits);
766 case Intrinsic::smax:
767 return APInt::getSignedMaxValue(numBits);
768 default:
769 llvm_unreachable("Invalid intrinsic");
770 }
771 }
772
773 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
774 /// so there is a certain threshold value, upon reaching which,
775 /// their value can no longer change. Return said threshold.
776 APInt getSaturationPoint(unsigned numBits) const {
777 return getSaturationPoint(getIntrinsicID(), numBits);
778 }
779
780 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
781 /// so there is a certain threshold value, upon reaching which,
782 /// their value can no longer change. Return said threshold.
786 }
787
788 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
789 /// so there is a certain threshold value, upon reaching which,
790 /// their value can no longer change. Return said threshold.
793 }
794};
795
796/// This class represents an intrinsic that is based on a binary operation.
797/// This includes op.with.overflow and saturating add/sub intrinsics.
799public:
800 static bool classof(const IntrinsicInst *I) {
801 switch (I->getIntrinsicID()) {
802 case Intrinsic::uadd_with_overflow:
803 case Intrinsic::sadd_with_overflow:
804 case Intrinsic::usub_with_overflow:
805 case Intrinsic::ssub_with_overflow:
806 case Intrinsic::umul_with_overflow:
807 case Intrinsic::smul_with_overflow:
808 case Intrinsic::uadd_sat:
809 case Intrinsic::sadd_sat:
810 case Intrinsic::usub_sat:
811 case Intrinsic::ssub_sat:
812 return true;
813 default:
814 return false;
815 }
816 }
817 static bool classof(const Value *V) {
818 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
819 }
820
821 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
822 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
823
824 /// Returns the binary operation underlying the intrinsic.
826
827 /// Whether the intrinsic is signed or unsigned.
828 bool isSigned() const;
829
830 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
831 unsigned getNoWrapKind() const;
832};
833
834/// Represents an op.with.overflow intrinsic.
836public:
837 static bool classof(const IntrinsicInst *I) {
838 switch (I->getIntrinsicID()) {
839 case Intrinsic::uadd_with_overflow:
840 case Intrinsic::sadd_with_overflow:
841 case Intrinsic::usub_with_overflow:
842 case Intrinsic::ssub_with_overflow:
843 case Intrinsic::umul_with_overflow:
844 case Intrinsic::smul_with_overflow:
845 return true;
846 default:
847 return false;
848 }
849 }
850 static bool classof(const Value *V) {
851 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
852 }
853};
854
855/// Represents a saturating add/sub intrinsic.
857public:
858 static bool classof(const IntrinsicInst *I) {
859 switch (I->getIntrinsicID()) {
860 case Intrinsic::uadd_sat:
861 case Intrinsic::sadd_sat:
862 case Intrinsic::usub_sat:
863 case Intrinsic::ssub_sat:
864 return true;
865 default:
866 return false;
867 }
868 }
869 static bool classof(const Value *V) {
870 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
871 }
872};
873
874/// Common base class for all memory intrinsics. Simply provides
875/// common methods.
876/// Written as CRTP to avoid a common base class amongst the
877/// three atomicity hierarchies.
878template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
879private:
880 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
881
882public:
883 Value *getRawDest() const {
884 return const_cast<Value *>(getArgOperand(ARG_DEST));
885 }
886 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
887 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
888
889 Value *getLength() const {
890 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
891 }
892 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
893 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
894
895 /// This is just like getRawDest, but it strips off any cast
896 /// instructions (including addrspacecast) that feed it, giving the
897 /// original input. The returned value is guaranteed to be a pointer.
898 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
899
900 unsigned getDestAddressSpace() const {
901 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
902 }
903
904 /// FIXME: Remove this function once transition to Align is over.
905 /// Use getDestAlign() instead.
906 LLVM_DEPRECATED("Use getDestAlign() instead", "getDestAlign")
908 if (auto MA = getParamAlign(ARG_DEST))
909 return MA->value();
910 return 0;
911 }
912 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
913
914 /// Set the specified arguments of the instruction.
916 assert(getRawDest()->getType() == Ptr->getType() &&
917 "setDest called with pointer of wrong type!");
918 setArgOperand(ARG_DEST, Ptr);
919 }
920
921 void setDestAlignment(MaybeAlign Alignment) {
922 removeParamAttr(ARG_DEST, Attribute::Alignment);
923 if (Alignment)
924 addParamAttr(ARG_DEST,
926 }
927 void setDestAlignment(Align Alignment) {
928 removeParamAttr(ARG_DEST, Attribute::Alignment);
929 addParamAttr(ARG_DEST,
931 }
932
933 void setLength(Value *L) {
934 assert(getLength()->getType() == L->getType() &&
935 "setLength called with value of wrong type!");
936 setArgOperand(ARG_LENGTH, L);
937 }
938};
939
940/// Common base class for all memory transfer intrinsics. Simply provides
941/// common methods.
942template <class BaseCL> class MemTransferBase : public BaseCL {
943private:
944 enum { ARG_SOURCE = 1 };
945
946public:
947 /// Return the arguments to the instruction.
949 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
950 }
951 const Use &getRawSourceUse() const {
952 return BaseCL::getArgOperandUse(ARG_SOURCE);
953 }
954 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
955
956 /// This is just like getRawSource, but it strips off any cast
957 /// instructions that feed it, giving the original input. The returned
958 /// value is guaranteed to be a pointer.
960
961 unsigned getSourceAddressSpace() const {
962 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
963 }
964
965 /// FIXME: Remove this function once transition to Align is over.
966 /// Use getSourceAlign() instead.
967 LLVM_DEPRECATED("Use getSourceAlign() instead", "getSourceAlign")
969 if (auto MA = BaseCL::getParamAlign(ARG_SOURCE))
970 return MA->value();
971 return 0;
972 }
973
975 return BaseCL::getParamAlign(ARG_SOURCE);
976 }
977
979 assert(getRawSource()->getType() == Ptr->getType() &&
980 "setSource called with pointer of wrong type!");
981 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
982 }
983
985 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
986 if (Alignment)
987 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
988 BaseCL::getContext(), *Alignment));
989 }
990
991 void setSourceAlignment(Align Alignment) {
992 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
993 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
994 BaseCL::getContext(), Alignment));
995 }
996};
997
998/// Common base class for all memset intrinsics. Simply provides
999/// common methods.
1000template <class BaseCL> class MemSetBase : public BaseCL {
1001private:
1002 enum { ARG_VALUE = 1 };
1003
1004public:
1005 Value *getValue() const {
1006 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1007 }
1008 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1009 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1010
1011 void setValue(Value *Val) {
1012 assert(getValue()->getType() == Val->getType() &&
1013 "setValue called with value of wrong type!");
1014 BaseCL::setArgOperand(ARG_VALUE, Val);
1015 }
1016};
1017
1018// The common base class for the atomic memset/memmove/memcpy intrinsics
1019// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1020class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
1021private:
1022 enum { ARG_ELEMENTSIZE = 3 };
1023
1024public:
1026 return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
1027 }
1028
1030 return cast<ConstantInt>(getRawElementSizeInBytes());
1031 }
1032
1035 }
1036
1038 assert(V->getType() == Type::getInt8Ty(getContext()) &&
1039 "setElementSizeInBytes called with value of wrong type!");
1040 setArgOperand(ARG_ELEMENTSIZE, V);
1041 }
1042
1043 static bool classof(const IntrinsicInst *I) {
1044 switch (I->getIntrinsicID()) {
1045 case Intrinsic::memcpy_element_unordered_atomic:
1046 case Intrinsic::memmove_element_unordered_atomic:
1047 case Intrinsic::memset_element_unordered_atomic:
1048 return true;
1049 default:
1050 return false;
1051 }
1052 }
1053 static bool classof(const Value *V) {
1054 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1055 }
1056};
1057
1058/// This class represents atomic memset intrinsic
1059// i.e. llvm.element.unordered.atomic.memset
1060class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
1061public:
1062 static bool classof(const IntrinsicInst *I) {
1063 return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
1064 }
1065 static bool classof(const Value *V) {
1066 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1067 }
1068};
1069
1070// This class wraps the atomic memcpy/memmove intrinsics
1071// i.e. llvm.element.unordered.atomic.memcpy/memmove
1072class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
1073public:
1074 static bool classof(const IntrinsicInst *I) {
1075 switch (I->getIntrinsicID()) {
1076 case Intrinsic::memcpy_element_unordered_atomic:
1077 case Intrinsic::memmove_element_unordered_atomic:
1078 return true;
1079 default:
1080 return false;
1081 }
1082 }
1083 static bool classof(const Value *V) {
1084 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1085 }
1086};
1087
1088/// This class represents the atomic memcpy intrinsic
1089/// i.e. llvm.element.unordered.atomic.memcpy
1091public:
1092 static bool classof(const IntrinsicInst *I) {
1093 return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
1094 }
1095 static bool classof(const Value *V) {
1096 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1097 }
1098};
1099
1100/// This class represents the atomic memmove intrinsic
1101/// i.e. llvm.element.unordered.atomic.memmove
1103public:
1104 static bool classof(const IntrinsicInst *I) {
1105 return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
1106 }
1107 static bool classof(const Value *V) {
1108 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1109 }
1110};
1111
1112/// This is the common base class for memset/memcpy/memmove.
1113class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1114private:
1115 enum { ARG_VOLATILE = 3 };
1116
1117public:
1119 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
1120 }
1121
1122 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1123
1124 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1125
1126 // Methods for support type inquiry through isa, cast, and dyn_cast:
1127 static bool classof(const IntrinsicInst *I) {
1128 switch (I->getIntrinsicID()) {
1129 case Intrinsic::memcpy:
1130 case Intrinsic::memmove:
1131 case Intrinsic::memset:
1132 case Intrinsic::memset_inline:
1133 case Intrinsic::memcpy_inline:
1134 return true;
1135 default:
1136 return false;
1137 }
1138 }
1139 static bool classof(const Value *V) {
1140 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1141 }
1142};
1143
1144/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1145class MemSetInst : public MemSetBase<MemIntrinsic> {
1146public:
1147 // Methods for support type inquiry through isa, cast, and dyn_cast:
1148 static bool classof(const IntrinsicInst *I) {
1149 switch (I->getIntrinsicID()) {
1150 case Intrinsic::memset:
1151 case Intrinsic::memset_inline:
1152 return true;
1153 default:
1154 return false;
1155 }
1156 }
1157 static bool classof(const Value *V) {
1158 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1159 }
1160};
1161
1162/// This class wraps the llvm.memset.inline intrinsic.
1164public:
1166 return cast<ConstantInt>(MemSetInst::getLength());
1167 }
1168 // Methods for support type inquiry through isa, cast, and dyn_cast:
1169 static bool classof(const IntrinsicInst *I) {
1170 return I->getIntrinsicID() == Intrinsic::memset_inline;
1171 }
1172 static bool classof(const Value *V) {
1173 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1174 }
1175};
1176
1177/// This class wraps the llvm.memcpy/memmove intrinsics.
1178class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1179public:
1180 // Methods for support type inquiry through isa, cast, and dyn_cast:
1181 static bool classof(const IntrinsicInst *I) {
1182 switch (I->getIntrinsicID()) {
1183 case Intrinsic::memcpy:
1184 case Intrinsic::memmove:
1185 case Intrinsic::memcpy_inline:
1186 return true;
1187 default:
1188 return false;
1189 }
1190 }
1191 static bool classof(const Value *V) {
1192 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1193 }
1194};
1195
1196/// This class wraps the llvm.memcpy intrinsic.
1198public:
1199 // Methods for support type inquiry through isa, cast, and dyn_cast:
1200 static bool classof(const IntrinsicInst *I) {
1201 return I->getIntrinsicID() == Intrinsic::memcpy ||
1202 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1203 }
1204 static bool classof(const Value *V) {
1205 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1206 }
1207};
1208
1209/// This class wraps the llvm.memmove intrinsic.
1211public:
1212 // Methods for support type inquiry through isa, cast, and dyn_cast:
1213 static bool classof(const IntrinsicInst *I) {
1214 return I->getIntrinsicID() == Intrinsic::memmove;
1215 }
1216 static bool classof(const Value *V) {
1217 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1218 }
1219};
1220
1221/// This class wraps the llvm.memcpy.inline intrinsic.
1223public:
1225 return cast<ConstantInt>(MemCpyInst::getLength());
1226 }
1227 // Methods for support type inquiry through isa, cast, and dyn_cast:
1228 static bool classof(const IntrinsicInst *I) {
1229 return I->getIntrinsicID() == Intrinsic::memcpy_inline;
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> {
1241public:
1242 bool isVolatile() const {
1243 // Only the non-atomic intrinsics can be volatile
1244 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1245 return MI->isVolatile();
1246 return false;
1247 }
1248
1249 static bool classof(const IntrinsicInst *I) {
1250 switch (I->getIntrinsicID()) {
1251 case Intrinsic::memcpy:
1252 case Intrinsic::memcpy_inline:
1253 case Intrinsic::memmove:
1254 case Intrinsic::memset:
1255 case Intrinsic::memset_inline:
1256 case Intrinsic::memcpy_element_unordered_atomic:
1257 case Intrinsic::memmove_element_unordered_atomic:
1258 case Intrinsic::memset_element_unordered_atomic:
1259 return true;
1260 default:
1261 return false;
1262 }
1263 }
1264 static bool classof(const Value *V) {
1265 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1266 }
1267};
1268
1269/// This class represents any memset intrinsic
1270// i.e. llvm.element.unordered.atomic.memset
1271// and llvm.memset
1272class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1273public:
1274 static bool classof(const IntrinsicInst *I) {
1275 switch (I->getIntrinsicID()) {
1276 case Intrinsic::memset:
1277 case Intrinsic::memset_inline:
1278 case Intrinsic::memset_element_unordered_atomic:
1279 return true;
1280 default:
1281 return false;
1282 }
1283 }
1284 static bool classof(const Value *V) {
1285 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1286 }
1287};
1288
1289// This class wraps any memcpy/memmove intrinsics
1290// i.e. llvm.element.unordered.atomic.memcpy/memmove
1291// and llvm.memcpy/memmove
1292class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1293public:
1294 static bool classof(const IntrinsicInst *I) {
1295 switch (I->getIntrinsicID()) {
1296 case Intrinsic::memcpy:
1297 case Intrinsic::memcpy_inline:
1298 case Intrinsic::memmove:
1299 case Intrinsic::memcpy_element_unordered_atomic:
1300 case Intrinsic::memmove_element_unordered_atomic:
1301 return true;
1302 default:
1303 return false;
1304 }
1305 }
1306 static bool classof(const Value *V) {
1307 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1308 }
1309};
1310
1311/// This class represents any memcpy intrinsic
1312/// i.e. llvm.element.unordered.atomic.memcpy
1313/// and llvm.memcpy
1315public:
1316 static bool classof(const IntrinsicInst *I) {
1317 switch (I->getIntrinsicID()) {
1318 case Intrinsic::memcpy:
1319 case Intrinsic::memcpy_inline:
1320 case Intrinsic::memcpy_element_unordered_atomic:
1321 return true;
1322 default:
1323 return false;
1324 }
1325 }
1326 static bool classof(const Value *V) {
1327 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1328 }
1329};
1330
1331/// This class represents any memmove intrinsic
1332/// i.e. llvm.element.unordered.atomic.memmove
1333/// and llvm.memmove
1335public:
1336 static bool classof(const IntrinsicInst *I) {
1337 switch (I->getIntrinsicID()) {
1338 case Intrinsic::memmove:
1339 case Intrinsic::memmove_element_unordered_atomic:
1340 return true;
1341 default:
1342 return false;
1343 }
1344 }
1345 static bool classof(const Value *V) {
1346 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1347 }
1348};
1349
1350/// This represents the llvm.va_start intrinsic.
1352public:
1353 static bool classof(const IntrinsicInst *I) {
1354 return I->getIntrinsicID() == Intrinsic::vastart;
1355 }
1356 static bool classof(const Value *V) {
1357 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1358 }
1359
1360 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1361};
1362
1363/// This represents the llvm.va_end intrinsic.
1364class VAEndInst : public IntrinsicInst {
1365public:
1366 static bool classof(const IntrinsicInst *I) {
1367 return I->getIntrinsicID() == Intrinsic::vaend;
1368 }
1369 static bool classof(const Value *V) {
1370 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1371 }
1372
1373 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1374};
1375
1376/// This represents the llvm.va_copy intrinsic.
1378public:
1379 static bool classof(const IntrinsicInst *I) {
1380 return I->getIntrinsicID() == Intrinsic::vacopy;
1381 }
1382 static bool classof(const Value *V) {
1383 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1384 }
1385
1386 Value *getDest() const { return const_cast<Value *>(getArgOperand(0)); }
1387 Value *getSrc() const { return const_cast<Value *>(getArgOperand(1)); }
1388};
1389
1390/// A base class for all instrprof intrinsics.
1392public:
1393 // The name of the instrumented function.
1395 return cast<GlobalVariable>(
1396 const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
1397 }
1398 // The hash of the CFG for the instrumented function.
1400 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1401 }
1402 // The number of counters for the instrumented function.
1403 ConstantInt *getNumCounters() const;
1404 // The index of the counter that this instruction acts on.
1405 ConstantInt *getIndex() const;
1406};
1407
1408/// This represents the llvm.instrprof.cover intrinsic.
1410public:
1411 static bool classof(const IntrinsicInst *I) {
1412 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1413 }
1414 static bool classof(const Value *V) {
1415 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1416 }
1417};
1418
1419/// This represents the llvm.instrprof.increment intrinsic.
1421public:
1422 static bool classof(const IntrinsicInst *I) {
1423 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1424 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1425 }
1426 static bool classof(const Value *V) {
1427 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1428 }
1429 Value *getStep() const;
1430};
1431
1432/// This represents the llvm.instrprof.increment.step intrinsic.
1434public:
1435 static bool classof(const IntrinsicInst *I) {
1436 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1437 }
1438 static bool classof(const Value *V) {
1439 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1440 }
1441};
1442
1443/// This represents the llvm.instrprof.timestamp intrinsic.
1445public:
1446 static bool classof(const IntrinsicInst *I) {
1447 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1448 }
1449 static bool classof(const Value *V) {
1450 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1451 }
1452};
1453
1454/// This represents the llvm.instrprof.value.profile intrinsic.
1456public:
1457 static bool classof(const IntrinsicInst *I) {
1458 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1459 }
1460 static bool classof(const Value *V) {
1461 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1462 }
1463
1465 return cast<Value>(const_cast<Value *>(getArgOperand(2)));
1466 }
1467
1469 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1470 }
1471
1472 // Returns the value site index.
1474 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
1475 }
1476};
1477
1479public:
1480 static bool classof(const IntrinsicInst *I) {
1481 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1482 }
1483
1484 static bool classof(const Value *V) {
1485 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1486 }
1487
1489 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(0)));
1490 }
1491
1493 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1494 }
1495
1497 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1498 }
1499
1501 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1502 }
1503};
1504
1506public:
1507 static bool classof(const IntrinsicInst *I) {
1508 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1509 }
1510
1511 static bool classof(const Value *V) {
1512 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1513 }
1514
1516 auto *MV =
1517 cast<MetadataAsValue>(getOperand(Intrinsic::NoAliasScopeDeclScopeArg));
1518 return cast<MDNode>(MV->getMetadata());
1519 }
1520
1521 void setScopeList(MDNode *ScopeList) {
1523 MetadataAsValue::get(getContext(), ScopeList));
1524 }
1525};
1526
1527/// Common base class for representing values projected from a statepoint.
1528/// Currently, the only projections available are gc.result and gc.relocate.
1530public:
1531 static bool classof(const IntrinsicInst *I) {
1532 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1533 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1534 }
1535
1536 static bool classof(const Value *V) {
1537 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1538 }
1539
1540 /// Return true if this relocate is tied to the invoke statepoint.
1541 /// This includes relocates which are on the unwinding path.
1542 bool isTiedToInvoke() const {
1543 const Value *Token = getArgOperand(0);
1544
1545 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1546 }
1547
1548 /// The statepoint with which this gc.relocate is associated.
1549 const Value *getStatepoint() const;
1550};
1551
1552/// Represents calls to the gc.relocate intrinsic.
1554public:
1555 static bool classof(const IntrinsicInst *I) {
1556 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1557 }
1558
1559 static bool classof(const Value *V) {
1560 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1561 }
1562
1563 /// The index into the associate statepoint's argument list
1564 /// which contains the base pointer of the pointer whose
1565 /// relocation this gc.relocate describes.
1566 unsigned getBasePtrIndex() const {
1567 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1568 }
1569
1570 /// The index into the associate statepoint's argument list which
1571 /// contains the pointer whose relocation this gc.relocate describes.
1572 unsigned getDerivedPtrIndex() const {
1573 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1574 }
1575
1576 Value *getBasePtr() const;
1577 Value *getDerivedPtr() const;
1578};
1579
1580/// Represents calls to the gc.result intrinsic.
1582public:
1583 static bool classof(const IntrinsicInst *I) {
1584 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1585 }
1586
1587 static bool classof(const Value *V) {
1588 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1589 }
1590};
1591
1592
1593/// This represents the llvm.assume intrinsic.
1595public:
1596 static bool classof(const IntrinsicInst *I) {
1597 return I->getIntrinsicID() == Intrinsic::assume;
1598 }
1599 static bool classof(const Value *V) {
1600 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1601 }
1602};
1603
1604} // end namespace llvm
1605
1606#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:145
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:75
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
Definition: APInt.h:186
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
Definition: APInt.h:189
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
Definition: APInt.h:196
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Definition: APInt.h:199
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:167
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:1589
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1412
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: InstrTypes.h:1763
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Definition: InstrTypes.h:1368
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1357
void setArgOperand(unsigned i, Value *v)
Definition: InstrTypes.h:1362
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1542
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:711
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:740
@ ICMP_UGT
unsigned greater than
Definition: InstrTypes.h:734
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:738
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:736
bool isSigned() const
Definition: InstrTypes.h:961
This is the shared class of boolean and integer constants.
Definition: Constants.h:78
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Definition: Constants.h:197
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:145
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:386
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)
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)
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:204
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)
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.
ConstantInt * getNumCounters() const
GlobalVariable * getName() const
ConstantInt * getHash() const
ConstantInt * getIndex() const
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.
Definition: IntrinsicInst.h:89
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:60
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:
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:950
LLVMContext & getContext() const
Definition: Metadata.h:1114
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:102
Root of the metadata hierarchy.
Definition: Metadata.h:61
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:1743
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:365
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
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 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.
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)
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< unsigned > 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:344
Value * getValue() const
Definition: Metadata.h:384
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:688
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1069
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:1826
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.
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