LLVM 18.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 intrinsic ID
600 std::optional<unsigned> getFunctionalIntrinsicID() const {
602 }
603
604 // Equivalent non-predicated constrained ID
605 std::optional<unsigned> getConstrainedIntrinsicID() const {
607 }
608
609 // Equivalent non-predicated opcode
610 static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
611
612 // Equivalent non-predicated intrinsic ID
613 static std::optional<Intrinsic::ID>
615
616 // Equivalent non-predicated constrained ID
617 static std::optional<Intrinsic::ID>
619};
620
621/// This represents vector predication reduction intrinsics.
623public:
624 static bool isVPReduction(Intrinsic::ID ID);
625
626 unsigned getStartParamPos() const;
627 unsigned getVectorParamPos() const;
628
629 static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
630 static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
631
632 /// Methods for support type inquiry through isa, cast, and dyn_cast:
633 /// @{
634 static bool classof(const IntrinsicInst *I) {
635 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
636 }
637 static bool classof(const Value *V) {
638 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
639 }
640 /// @}
641};
642
644public:
645 static bool isVPCast(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 VPCastIntrinsic::isVPCast(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 isVPCmp(Intrinsic::ID ID);
661
663
664 /// Methods for support type inquiry through isa, cast, and dyn_cast:
665 /// @{
666 static bool classof(const IntrinsicInst *I) {
667 return VPCmpIntrinsic::isVPCmp(I->getIntrinsicID());
668 }
669 static bool classof(const Value *V) {
670 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
671 }
672 /// @}
673};
674
676public:
677 static bool isVPBinOp(Intrinsic::ID ID);
678
679 /// Methods for support type inquiry through isa, cast, and dyn_cast:
680 /// @{
681 static bool classof(const IntrinsicInst *I) {
682 return VPBinOpIntrinsic::isVPBinOp(I->getIntrinsicID());
683 }
684 static bool classof(const Value *V) {
685 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
686 }
687 /// @}
688};
689
690
691/// This is the common base class for constrained floating point intrinsics.
693public:
694 bool isUnaryOp() const;
695 bool isTernaryOp() const;
696 std::optional<RoundingMode> getRoundingMode() const;
697 std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
698 bool isDefaultFPEnvironment() const;
699
700 // Methods for support type inquiry through isa, cast, and dyn_cast:
701 static bool classof(const IntrinsicInst *I);
702 static bool classof(const Value *V) {
703 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
704 }
705};
706
707/// Constrained floating point compare intrinsics.
709public:
711 bool isSignaling() const {
712 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
713 }
714
715 // Methods for support type inquiry through isa, cast, and dyn_cast:
716 static bool classof(const IntrinsicInst *I) {
717 switch (I->getIntrinsicID()) {
718 case Intrinsic::experimental_constrained_fcmp:
719 case Intrinsic::experimental_constrained_fcmps:
720 return true;
721 default:
722 return false;
723 }
724 }
725 static bool classof(const Value *V) {
726 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
727 }
728};
729
730/// This class represents min/max intrinsics.
732public:
733 static bool classof(const IntrinsicInst *I) {
734 switch (I->getIntrinsicID()) {
735 case Intrinsic::umin:
736 case Intrinsic::umax:
737 case Intrinsic::smin:
738 case Intrinsic::smax:
739 return true;
740 default:
741 return false;
742 }
743 }
744 static bool classof(const Value *V) {
745 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
746 }
747
748 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
749 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
750
751 /// Returns the comparison predicate underlying the intrinsic.
753 switch (ID) {
754 case Intrinsic::umin:
756 case Intrinsic::umax:
758 case Intrinsic::smin:
760 case Intrinsic::smax:
762 default:
763 llvm_unreachable("Invalid intrinsic");
764 }
765 }
766
767 /// Returns the comparison predicate underlying the intrinsic.
770 }
771
772 /// Whether the intrinsic is signed or unsigned.
773 static bool isSigned(Intrinsic::ID ID) {
775 };
776
777 /// Whether the intrinsic is signed or unsigned.
778 bool isSigned() const { return isSigned(getIntrinsicID()); };
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.
783 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
784 switch (ID) {
785 case Intrinsic::umin:
786 return APInt::getMinValue(numBits);
787 case Intrinsic::umax:
788 return APInt::getMaxValue(numBits);
789 case Intrinsic::smin:
790 return APInt::getSignedMinValue(numBits);
791 case Intrinsic::smax:
792 return APInt::getSignedMaxValue(numBits);
793 default:
794 llvm_unreachable("Invalid intrinsic");
795 }
796 }
797
798 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
799 /// so there is a certain threshold value, upon reaching which,
800 /// their value can no longer change. Return said threshold.
801 APInt getSaturationPoint(unsigned numBits) const {
802 return getSaturationPoint(getIntrinsicID(), numBits);
803 }
804
805 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
806 /// so there is a certain threshold value, upon reaching which,
807 /// their value can no longer change. Return said threshold.
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.
818 }
819};
820
821/// This class represents an intrinsic that is based on a binary operation.
822/// This includes op.with.overflow and saturating add/sub intrinsics.
824public:
825 static bool classof(const IntrinsicInst *I) {
826 switch (I->getIntrinsicID()) {
827 case Intrinsic::uadd_with_overflow:
828 case Intrinsic::sadd_with_overflow:
829 case Intrinsic::usub_with_overflow:
830 case Intrinsic::ssub_with_overflow:
831 case Intrinsic::umul_with_overflow:
832 case Intrinsic::smul_with_overflow:
833 case Intrinsic::uadd_sat:
834 case Intrinsic::sadd_sat:
835 case Intrinsic::usub_sat:
836 case Intrinsic::ssub_sat:
837 return true;
838 default:
839 return false;
840 }
841 }
842 static bool classof(const Value *V) {
843 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
844 }
845
846 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
847 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
848
849 /// Returns the binary operation underlying the intrinsic.
851
852 /// Whether the intrinsic is signed or unsigned.
853 bool isSigned() const;
854
855 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
856 unsigned getNoWrapKind() const;
857};
858
859/// Represents an op.with.overflow intrinsic.
861public:
862 static bool classof(const IntrinsicInst *I) {
863 switch (I->getIntrinsicID()) {
864 case Intrinsic::uadd_with_overflow:
865 case Intrinsic::sadd_with_overflow:
866 case Intrinsic::usub_with_overflow:
867 case Intrinsic::ssub_with_overflow:
868 case Intrinsic::umul_with_overflow:
869 case Intrinsic::smul_with_overflow:
870 return true;
871 default:
872 return false;
873 }
874 }
875 static bool classof(const Value *V) {
876 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
877 }
878};
879
880/// Represents a saturating add/sub intrinsic.
882public:
883 static bool classof(const IntrinsicInst *I) {
884 switch (I->getIntrinsicID()) {
885 case Intrinsic::uadd_sat:
886 case Intrinsic::sadd_sat:
887 case Intrinsic::usub_sat:
888 case Intrinsic::ssub_sat:
889 return true;
890 default:
891 return false;
892 }
893 }
894 static bool classof(const Value *V) {
895 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
896 }
897};
898
899/// Common base class for all memory intrinsics. Simply provides
900/// common methods.
901/// Written as CRTP to avoid a common base class amongst the
902/// three atomicity hierarchies.
903template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
904private:
905 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
906
907public:
908 Value *getRawDest() const {
909 return const_cast<Value *>(getArgOperand(ARG_DEST));
910 }
911 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
912 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
913
914 Value *getLength() const {
915 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
916 }
917 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
918 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
919
920 /// This is just like getRawDest, but it strips off any cast
921 /// instructions (including addrspacecast) that feed it, giving the
922 /// original input. The returned value is guaranteed to be a pointer.
923 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
924
925 unsigned getDestAddressSpace() const {
926 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
927 }
928
929 /// FIXME: Remove this function once transition to Align is over.
930 /// Use getDestAlign() instead.
931 LLVM_DEPRECATED("Use getDestAlign() instead", "getDestAlign")
933 if (auto MA = getParamAlign(ARG_DEST))
934 return MA->value();
935 return 0;
936 }
937 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
938
939 /// Set the specified arguments of the instruction.
941 assert(getRawDest()->getType() == Ptr->getType() &&
942 "setDest called with pointer of wrong type!");
943 setArgOperand(ARG_DEST, Ptr);
944 }
945
946 void setDestAlignment(MaybeAlign Alignment) {
947 removeParamAttr(ARG_DEST, Attribute::Alignment);
948 if (Alignment)
949 addParamAttr(ARG_DEST,
951 }
952 void setDestAlignment(Align Alignment) {
953 removeParamAttr(ARG_DEST, Attribute::Alignment);
954 addParamAttr(ARG_DEST,
956 }
957
958 void setLength(Value *L) {
959 assert(getLength()->getType() == L->getType() &&
960 "setLength called with value of wrong type!");
961 setArgOperand(ARG_LENGTH, L);
962 }
963};
964
965/// Common base class for all memory transfer intrinsics. Simply provides
966/// common methods.
967template <class BaseCL> class MemTransferBase : public BaseCL {
968private:
969 enum { ARG_SOURCE = 1 };
970
971public:
972 /// Return the arguments to the instruction.
974 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
975 }
976 const Use &getRawSourceUse() const {
977 return BaseCL::getArgOperandUse(ARG_SOURCE);
978 }
979 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
980
981 /// This is just like getRawSource, but it strips off any cast
982 /// instructions that feed it, giving the original input. The returned
983 /// value is guaranteed to be a pointer.
985
986 unsigned getSourceAddressSpace() const {
987 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
988 }
989
990 /// FIXME: Remove this function once transition to Align is over.
991 /// Use getSourceAlign() instead.
992 LLVM_DEPRECATED("Use getSourceAlign() instead", "getSourceAlign")
994 if (auto MA = BaseCL::getParamAlign(ARG_SOURCE))
995 return MA->value();
996 return 0;
997 }
998
1000 return BaseCL::getParamAlign(ARG_SOURCE);
1001 }
1002
1004 assert(getRawSource()->getType() == Ptr->getType() &&
1005 "setSource called with pointer of wrong type!");
1006 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1007 }
1008
1010 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1011 if (Alignment)
1012 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1013 BaseCL::getContext(), *Alignment));
1014 }
1015
1016 void setSourceAlignment(Align Alignment) {
1017 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1018 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1019 BaseCL::getContext(), Alignment));
1020 }
1021};
1022
1023/// Common base class for all memset intrinsics. Simply provides
1024/// common methods.
1025template <class BaseCL> class MemSetBase : public BaseCL {
1026private:
1027 enum { ARG_VALUE = 1 };
1028
1029public:
1030 Value *getValue() const {
1031 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1032 }
1033 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1034 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1035
1036 void setValue(Value *Val) {
1037 assert(getValue()->getType() == Val->getType() &&
1038 "setValue called with value of wrong type!");
1039 BaseCL::setArgOperand(ARG_VALUE, Val);
1040 }
1041};
1042
1043// The common base class for the atomic memset/memmove/memcpy intrinsics
1044// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1045class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
1046private:
1047 enum { ARG_ELEMENTSIZE = 3 };
1048
1049public:
1051 return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
1052 }
1053
1055 return cast<ConstantInt>(getRawElementSizeInBytes());
1056 }
1057
1060 }
1061
1063 assert(V->getType() == Type::getInt8Ty(getContext()) &&
1064 "setElementSizeInBytes called with value of wrong type!");
1065 setArgOperand(ARG_ELEMENTSIZE, V);
1066 }
1067
1068 static bool classof(const IntrinsicInst *I) {
1069 switch (I->getIntrinsicID()) {
1070 case Intrinsic::memcpy_element_unordered_atomic:
1071 case Intrinsic::memmove_element_unordered_atomic:
1072 case Intrinsic::memset_element_unordered_atomic:
1073 return true;
1074 default:
1075 return false;
1076 }
1077 }
1078 static bool classof(const Value *V) {
1079 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1080 }
1081};
1082
1083/// This class represents atomic memset intrinsic
1084// i.e. llvm.element.unordered.atomic.memset
1085class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
1086public:
1087 static bool classof(const IntrinsicInst *I) {
1088 return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
1089 }
1090 static bool classof(const Value *V) {
1091 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1092 }
1093};
1094
1095// This class wraps the atomic memcpy/memmove intrinsics
1096// i.e. llvm.element.unordered.atomic.memcpy/memmove
1097class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
1098public:
1099 static bool classof(const IntrinsicInst *I) {
1100 switch (I->getIntrinsicID()) {
1101 case Intrinsic::memcpy_element_unordered_atomic:
1102 case Intrinsic::memmove_element_unordered_atomic:
1103 return true;
1104 default:
1105 return false;
1106 }
1107 }
1108 static bool classof(const Value *V) {
1109 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1110 }
1111};
1112
1113/// This class represents the atomic memcpy intrinsic
1114/// i.e. llvm.element.unordered.atomic.memcpy
1116public:
1117 static bool classof(const IntrinsicInst *I) {
1118 return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
1119 }
1120 static bool classof(const Value *V) {
1121 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1122 }
1123};
1124
1125/// This class represents the atomic memmove intrinsic
1126/// i.e. llvm.element.unordered.atomic.memmove
1128public:
1129 static bool classof(const IntrinsicInst *I) {
1130 return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
1131 }
1132 static bool classof(const Value *V) {
1133 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1134 }
1135};
1136
1137/// This is the common base class for memset/memcpy/memmove.
1138class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1139private:
1140 enum { ARG_VOLATILE = 3 };
1141
1142public:
1144 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
1145 }
1146
1147 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1148
1149 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1150
1151 // Methods for support type inquiry through isa, cast, and dyn_cast:
1152 static bool classof(const IntrinsicInst *I) {
1153 switch (I->getIntrinsicID()) {
1154 case Intrinsic::memcpy:
1155 case Intrinsic::memmove:
1156 case Intrinsic::memset:
1157 case Intrinsic::memset_inline:
1158 case Intrinsic::memcpy_inline:
1159 return true;
1160 default:
1161 return false;
1162 }
1163 }
1164 static bool classof(const Value *V) {
1165 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1166 }
1167};
1168
1169/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1170class MemSetInst : public MemSetBase<MemIntrinsic> {
1171public:
1172 // Methods for support type inquiry through isa, cast, and dyn_cast:
1173 static bool classof(const IntrinsicInst *I) {
1174 switch (I->getIntrinsicID()) {
1175 case Intrinsic::memset:
1176 case Intrinsic::memset_inline:
1177 return true;
1178 default:
1179 return false;
1180 }
1181 }
1182 static bool classof(const Value *V) {
1183 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1184 }
1185};
1186
1187/// This class wraps the llvm.memset.inline intrinsic.
1189public:
1191 return cast<ConstantInt>(MemSetInst::getLength());
1192 }
1193 // Methods for support type inquiry through isa, cast, and dyn_cast:
1194 static bool classof(const IntrinsicInst *I) {
1195 return I->getIntrinsicID() == Intrinsic::memset_inline;
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.memcpy/memmove intrinsics.
1203class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1204public:
1205 // Methods for support type inquiry through isa, cast, and dyn_cast:
1206 static bool classof(const IntrinsicInst *I) {
1207 switch (I->getIntrinsicID()) {
1208 case Intrinsic::memcpy:
1209 case Intrinsic::memmove:
1210 case Intrinsic::memcpy_inline:
1211 return true;
1212 default:
1213 return false;
1214 }
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 intrinsic.
1223public:
1224 // Methods for support type inquiry through isa, cast, and dyn_cast:
1225 static bool classof(const IntrinsicInst *I) {
1226 return I->getIntrinsicID() == Intrinsic::memcpy ||
1227 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1228 }
1229 static bool classof(const Value *V) {
1230 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1231 }
1232};
1233
1234/// This class wraps the llvm.memmove intrinsic.
1236public:
1237 // Methods for support type inquiry through isa, cast, and dyn_cast:
1238 static bool classof(const IntrinsicInst *I) {
1239 return I->getIntrinsicID() == Intrinsic::memmove;
1240 }
1241 static bool classof(const Value *V) {
1242 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1243 }
1244};
1245
1246/// This class wraps the llvm.memcpy.inline intrinsic.
1248public:
1250 return cast<ConstantInt>(MemCpyInst::getLength());
1251 }
1252 // Methods for support type inquiry through isa, cast, and dyn_cast:
1253 static bool classof(const IntrinsicInst *I) {
1254 return I->getIntrinsicID() == Intrinsic::memcpy_inline;
1255 }
1256 static bool classof(const Value *V) {
1257 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1258 }
1259};
1260
1261// The common base class for any memset/memmove/memcpy intrinsics;
1262// whether they be atomic or non-atomic.
1263// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1264// and llvm.memset/memcpy/memmove
1265class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1266public:
1267 bool isVolatile() const {
1268 // Only the non-atomic intrinsics can be volatile
1269 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1270 return MI->isVolatile();
1271 return false;
1272 }
1273
1274 static bool classof(const IntrinsicInst *I) {
1275 switch (I->getIntrinsicID()) {
1276 case Intrinsic::memcpy:
1277 case Intrinsic::memcpy_inline:
1278 case Intrinsic::memmove:
1279 case Intrinsic::memset:
1280 case Intrinsic::memset_inline:
1281 case Intrinsic::memcpy_element_unordered_atomic:
1282 case Intrinsic::memmove_element_unordered_atomic:
1283 case Intrinsic::memset_element_unordered_atomic:
1284 return true;
1285 default:
1286 return false;
1287 }
1288 }
1289 static bool classof(const Value *V) {
1290 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1291 }
1292};
1293
1294/// This class represents any memset intrinsic
1295// i.e. llvm.element.unordered.atomic.memset
1296// and llvm.memset
1297class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1298public:
1299 static bool classof(const IntrinsicInst *I) {
1300 switch (I->getIntrinsicID()) {
1301 case Intrinsic::memset:
1302 case Intrinsic::memset_inline:
1303 case Intrinsic::memset_element_unordered_atomic:
1304 return true;
1305 default:
1306 return false;
1307 }
1308 }
1309 static bool classof(const Value *V) {
1310 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1311 }
1312};
1313
1314// This class wraps any memcpy/memmove intrinsics
1315// i.e. llvm.element.unordered.atomic.memcpy/memmove
1316// and llvm.memcpy/memmove
1317class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1318public:
1319 static bool classof(const IntrinsicInst *I) {
1320 switch (I->getIntrinsicID()) {
1321 case Intrinsic::memcpy:
1322 case Intrinsic::memcpy_inline:
1323 case Intrinsic::memmove:
1324 case Intrinsic::memcpy_element_unordered_atomic:
1325 case Intrinsic::memmove_element_unordered_atomic:
1326 return true;
1327 default:
1328 return false;
1329 }
1330 }
1331 static bool classof(const Value *V) {
1332 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1333 }
1334};
1335
1336/// This class represents any memcpy intrinsic
1337/// i.e. llvm.element.unordered.atomic.memcpy
1338/// and llvm.memcpy
1340public:
1341 static bool classof(const IntrinsicInst *I) {
1342 switch (I->getIntrinsicID()) {
1343 case Intrinsic::memcpy:
1344 case Intrinsic::memcpy_inline:
1345 case Intrinsic::memcpy_element_unordered_atomic:
1346 return true;
1347 default:
1348 return false;
1349 }
1350 }
1351 static bool classof(const Value *V) {
1352 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1353 }
1354};
1355
1356/// This class represents any memmove intrinsic
1357/// i.e. llvm.element.unordered.atomic.memmove
1358/// and llvm.memmove
1360public:
1361 static bool classof(const IntrinsicInst *I) {
1362 switch (I->getIntrinsicID()) {
1363 case Intrinsic::memmove:
1364 case Intrinsic::memmove_element_unordered_atomic:
1365 return true;
1366 default:
1367 return false;
1368 }
1369 }
1370 static bool classof(const Value *V) {
1371 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1372 }
1373};
1374
1375/// This represents the llvm.va_start intrinsic.
1377public:
1378 static bool classof(const IntrinsicInst *I) {
1379 return I->getIntrinsicID() == Intrinsic::vastart;
1380 }
1381 static bool classof(const Value *V) {
1382 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1383 }
1384
1385 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1386};
1387
1388/// This represents the llvm.va_end intrinsic.
1389class VAEndInst : public IntrinsicInst {
1390public:
1391 static bool classof(const IntrinsicInst *I) {
1392 return I->getIntrinsicID() == Intrinsic::vaend;
1393 }
1394 static bool classof(const Value *V) {
1395 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1396 }
1397
1398 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1399};
1400
1401/// This represents the llvm.va_copy intrinsic.
1403public:
1404 static bool classof(const IntrinsicInst *I) {
1405 return I->getIntrinsicID() == Intrinsic::vacopy;
1406 }
1407 static bool classof(const Value *V) {
1408 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1409 }
1410
1411 Value *getDest() const { return const_cast<Value *>(getArgOperand(0)); }
1412 Value *getSrc() const { return const_cast<Value *>(getArgOperand(1)); }
1413};
1414
1415/// A base class for all instrprof intrinsics.
1417public:
1418 // The name of the instrumented function.
1420 return cast<GlobalVariable>(
1421 const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
1422 }
1423 // The hash of the CFG for the instrumented function.
1425 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1426 }
1427 // The number of counters for the instrumented function.
1428 ConstantInt *getNumCounters() const;
1429 // The index of the counter that this instruction acts on.
1430 ConstantInt *getIndex() const;
1431};
1432
1433/// This represents the llvm.instrprof.cover intrinsic.
1435public:
1436 static bool classof(const IntrinsicInst *I) {
1437 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1438 }
1439 static bool classof(const Value *V) {
1440 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1441 }
1442};
1443
1444/// This represents the llvm.instrprof.increment intrinsic.
1446public:
1447 static bool classof(const IntrinsicInst *I) {
1448 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1449 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1450 }
1451 static bool classof(const Value *V) {
1452 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1453 }
1454 Value *getStep() const;
1455};
1456
1457/// This represents the llvm.instrprof.increment.step intrinsic.
1459public:
1460 static bool classof(const IntrinsicInst *I) {
1461 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1462 }
1463 static bool classof(const Value *V) {
1464 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1465 }
1466};
1467
1468/// This represents the llvm.instrprof.timestamp intrinsic.
1470public:
1471 static bool classof(const IntrinsicInst *I) {
1472 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1473 }
1474 static bool classof(const Value *V) {
1475 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1476 }
1477};
1478
1479/// This represents the llvm.instrprof.value.profile intrinsic.
1481public:
1482 static bool classof(const IntrinsicInst *I) {
1483 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1484 }
1485 static bool classof(const Value *V) {
1486 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1487 }
1488
1490 return cast<Value>(const_cast<Value *>(getArgOperand(2)));
1491 }
1492
1494 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1495 }
1496
1497 // Returns the value site index.
1499 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
1500 }
1501};
1502
1504public:
1505 static bool classof(const IntrinsicInst *I) {
1506 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1507 }
1508
1509 static bool classof(const Value *V) {
1510 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1511 }
1512
1514 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(0)));
1515 }
1516
1518 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1519 }
1520
1522 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1523 }
1524
1526 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1527 }
1528};
1529
1531public:
1532 static bool classof(const IntrinsicInst *I) {
1533 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1534 }
1535
1536 static bool classof(const Value *V) {
1537 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1538 }
1539
1541 auto *MV =
1542 cast<MetadataAsValue>(getOperand(Intrinsic::NoAliasScopeDeclScopeArg));
1543 return cast<MDNode>(MV->getMetadata());
1544 }
1545
1546 void setScopeList(MDNode *ScopeList) {
1548 MetadataAsValue::get(getContext(), ScopeList));
1549 }
1550};
1551
1552/// Common base class for representing values projected from a statepoint.
1553/// Currently, the only projections available are gc.result and gc.relocate.
1555public:
1556 static bool classof(const IntrinsicInst *I) {
1557 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1558 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1559 }
1560
1561 static bool classof(const Value *V) {
1562 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1563 }
1564
1565 /// Return true if this relocate is tied to the invoke statepoint.
1566 /// This includes relocates which are on the unwinding path.
1567 bool isTiedToInvoke() const {
1568 const Value *Token = getArgOperand(0);
1569
1570 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1571 }
1572
1573 /// The statepoint with which this gc.relocate is associated.
1574 const Value *getStatepoint() const;
1575};
1576
1577/// Represents calls to the gc.relocate intrinsic.
1579public:
1580 static bool classof(const IntrinsicInst *I) {
1581 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1582 }
1583
1584 static bool classof(const Value *V) {
1585 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1586 }
1587
1588 /// The index into the associate statepoint's argument list
1589 /// which contains the base pointer of the pointer whose
1590 /// relocation this gc.relocate describes.
1591 unsigned getBasePtrIndex() const {
1592 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1593 }
1594
1595 /// The index into the associate statepoint's argument list which
1596 /// contains the pointer whose relocation this gc.relocate describes.
1597 unsigned getDerivedPtrIndex() const {
1598 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1599 }
1600
1601 Value *getBasePtr() const;
1602 Value *getDerivedPtr() const;
1603};
1604
1605/// Represents calls to the gc.result intrinsic.
1607public:
1608 static bool classof(const IntrinsicInst *I) {
1609 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1610 }
1611
1612 static bool classof(const Value *V) {
1613 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1614 }
1615};
1616
1617
1618/// This represents the llvm.assume intrinsic.
1620public:
1621 static bool classof(const IntrinsicInst *I) {
1622 return I->getIntrinsicID() == Intrinsic::assume;
1623 }
1624 static bool classof(const Value *V) {
1625 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1626 }
1627};
1628
1629} // end namespace llvm
1630
1631#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:1588
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:1762
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:1541
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:206
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:366
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:451
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: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:1734
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