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