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 bool AllowEmpty = false);
316 void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
317 /// Adding a new location operand will always result in this intrinsic using
318 /// an ArgList, and must always be accompanied by a new expression that uses
319 /// the new operand.
322
324 setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
325 }
326
329 }
330
331 unsigned getNumVariableLocationOps() const {
333 }
334
335 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
336
337 /// Does this describe the address of a local variable. True for dbg.declare,
338 /// but not dbg.value, which describes its value, or dbg.assign, which
339 /// describes a combination of the variable's value and address.
340 bool isAddressOfVariable() const {
341 return getIntrinsicID() == Intrinsic::dbg_declare;
342 }
343
345 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
346 // this set anymore.
347 SmallPtrSet<Value *, 4> RemovedValues;
348 for (Value *OldValue : location_ops()) {
349 if (!RemovedValues.insert(OldValue).second)
350 continue;
351 Value *Poison = PoisonValue::get(OldValue->getType());
352 replaceVariableLocationOp(OldValue, Poison);
353 }
354 }
355
356 bool isKillLocation() const {
358 }
359
361 return cast<DILocalVariable>(getRawVariable());
362 }
363
365 return cast<DIExpression>(getRawExpression());
366 }
367
369 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
370 }
371
374 }
375
377 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
378 }
379
381 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
382 }
383
384 /// Use of this should generally be avoided; instead,
385 /// replaceVariableLocationOp and addVariableLocationOps should be used where
386 /// possible to avoid creating invalid state.
387 void setRawLocation(Metadata *Location) {
388 return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
389 }
390
391 /// Get the size (in bits) of the variable, or fragment of the variable that
392 /// is described.
393 std::optional<uint64_t> getFragmentSizeInBits() const;
394
395 /// Get the FragmentInfo for the variable.
396 std::optional<DIExpression::FragmentInfo> getFragment() const {
397 return getExpression()->getFragmentInfo();
398 }
399
400 /// Get the FragmentInfo for the variable if it exists, otherwise return a
401 /// FragmentInfo that covers the entire variable if the variable size is
402 /// known, otherwise return a zero-sized fragment.
404 DIExpression::FragmentInfo VariableSlice(0, 0);
405 // Get the fragment or variable size, or zero.
406 if (auto Sz = getFragmentSizeInBits())
407 VariableSlice.SizeInBits = *Sz;
408 if (auto Frag = getExpression()->getFragmentInfo())
409 VariableSlice.OffsetInBits = Frag->OffsetInBits;
410 return VariableSlice;
411 }
412
413 /// \name Casting methods
414 /// @{
415 static bool classof(const IntrinsicInst *I) {
416 switch (I->getIntrinsicID()) {
417 case Intrinsic::dbg_declare:
418 case Intrinsic::dbg_value:
419 case Intrinsic::dbg_assign:
420 return true;
421 default:
422 return false;
423 }
424 }
425 static bool classof(const Value *V) {
426 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
427 }
428 /// @}
429protected:
430 void setArgOperand(unsigned i, Value *v) {
432 }
433 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
434};
435
436/// This represents the llvm.dbg.declare instruction.
438public:
439 Value *getAddress() const {
441 "dbg.declare must have exactly 1 location operand.");
442 return getVariableLocationOp(0);
443 }
444
445 /// \name Casting methods
446 /// @{
447 static bool classof(const IntrinsicInst *I) {
448 return I->getIntrinsicID() == Intrinsic::dbg_declare;
449 }
450 static bool classof(const Value *V) {
451 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
452 }
453 /// @}
454};
455
456/// This represents the llvm.dbg.value instruction.
458public:
459 // The default argument should only be used in ISel, and the default option
460 // should be removed once ISel support for multiple location ops is complete.
461 Value *getValue(unsigned OpIdx = 0) const {
462 return getVariableLocationOp(OpIdx);
463 }
465 return location_ops();
466 }
467
468 /// \name Casting methods
469 /// @{
470 static bool classof(const IntrinsicInst *I) {
471 return I->getIntrinsicID() == Intrinsic::dbg_value ||
472 I->getIntrinsicID() == Intrinsic::dbg_assign;
473 }
474 static bool classof(const Value *V) {
475 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
476 }
477 /// @}
478};
479
480/// This represents the llvm.dbg.assign instruction.
482 enum Operands {
483 OpValue,
484 OpVar,
485 OpExpr,
486 OpAssignID,
487 OpAddress,
488 OpAddressExpr,
489 };
490
491public:
492 Value *getAddress() const;
494 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
495 }
497 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
498 }
499 DIAssignID *getAssignID() const { return cast<DIAssignID>(getRawAssignID()); }
501 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
502 }
504 return cast<DIExpression>(getRawAddressExpression());
505 }
507 setArgOperand(OpAddressExpr,
508 MetadataAsValue::get(NewExpr->getContext(), NewExpr));
509 }
510 void setAssignId(DIAssignID *New);
511 void setAddress(Value *V);
512 /// Kill the address component.
513 void setKillAddress();
514 /// Check whether this kills the address component. This doesn't take into
515 /// account the position of the intrinsic, therefore a returned value of false
516 /// does not guarentee the address is a valid location for the variable at the
517 /// intrinsic's position in IR.
518 bool isKillAddress() const;
519 void setValue(Value *V);
520 /// \name Casting methods
521 /// @{
522 static bool classof(const IntrinsicInst *I) {
523 return I->getIntrinsicID() == Intrinsic::dbg_assign;
524 }
525 static bool classof(const Value *V) {
526 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
527 }
528 /// @}
529};
530
531/// This represents the llvm.dbg.label instruction.
533public:
534 DILabel *getLabel() const { return cast<DILabel>(getRawLabel()); }
535 void setLabel(DILabel *NewLabel) {
537 }
538
540 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
541 }
542
543 /// Methods for support type inquiry through isa, cast, and dyn_cast:
544 /// @{
545 static bool classof(const IntrinsicInst *I) {
546 return I->getIntrinsicID() == Intrinsic::dbg_label;
547 }
548 static bool classof(const Value *V) {
549 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
550 }
551 /// @}
552};
553
554/// This is the common base class for vector predication intrinsics.
556public:
557 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
558 /// \p Params. Additionally, the load and gather intrinsics require
559 /// \p ReturnType to be specified.
561 Type *ReturnType,
562 ArrayRef<Value *> Params);
563
564 static std::optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
565 static std::optional<unsigned> getVectorLengthParamPos(
566 Intrinsic::ID IntrinsicID);
567
568 /// The llvm.vp.* intrinsics for this instruction Opcode
569 static Intrinsic::ID getForOpcode(unsigned OC);
570
571 // Whether \p ID is a VP intrinsic ID.
572 static bool isVPIntrinsic(Intrinsic::ID);
573
574 /// \return The mask parameter or nullptr.
575 Value *getMaskParam() const;
576 void setMaskParam(Value *);
577
578 /// \return The vector length parameter or nullptr.
581
582 /// \return Whether the vector length param can be ignored.
583 bool canIgnoreVectorLengthParam() const;
584
585 /// \return The static element count (vector number of elements) the vector
586 /// length parameter applies to.
588
589 /// \return The alignment of the pointer used by this load/store/gather or
590 /// scatter.
592 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
593
594 /// \return The pointer operand of this load,store, gather or scatter.
596 static std::optional<unsigned> getMemoryPointerParamPos(Intrinsic::ID);
597
598 /// \return The data (payload) operand of this store or scatter.
599 Value *getMemoryDataParam() const;
600 static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
601
602 // Methods for support type inquiry through isa, cast, and dyn_cast:
603 static bool classof(const IntrinsicInst *I) {
604 return isVPIntrinsic(I->getIntrinsicID());
605 }
606 static bool classof(const Value *V) {
607 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
608 }
609
610 // Equivalent non-predicated opcode
611 std::optional<unsigned> getFunctionalOpcode() const {
613 }
614
615 // Equivalent non-predicated intrinsic ID
616 std::optional<unsigned> getFunctionalIntrinsicID() const {
618 }
619
620 // Equivalent non-predicated constrained ID
621 std::optional<unsigned> getConstrainedIntrinsicID() const {
623 }
624
625 // Equivalent non-predicated opcode
626 static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
627
628 // Equivalent non-predicated intrinsic ID
629 static std::optional<Intrinsic::ID>
631
632 // Equivalent non-predicated constrained ID
633 static std::optional<Intrinsic::ID>
635};
636
637/// This represents vector predication reduction intrinsics.
639public:
640 static bool isVPReduction(Intrinsic::ID ID);
641
642 unsigned getStartParamPos() const;
643 unsigned getVectorParamPos() const;
644
645 static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
646 static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
647
648 /// Methods for support type inquiry through isa, cast, and dyn_cast:
649 /// @{
650 static bool classof(const IntrinsicInst *I) {
651 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
652 }
653 static bool classof(const Value *V) {
654 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
655 }
656 /// @}
657};
658
660public:
661 static bool isVPCast(Intrinsic::ID ID);
662
663 /// Methods for support type inquiry through isa, cast, and dyn_cast:
664 /// @{
665 static bool classof(const IntrinsicInst *I) {
666 return VPCastIntrinsic::isVPCast(I->getIntrinsicID());
667 }
668 static bool classof(const Value *V) {
669 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
670 }
671 /// @}
672};
673
675public:
676 static bool isVPCmp(Intrinsic::ID ID);
677
679
680 /// Methods for support type inquiry through isa, cast, and dyn_cast:
681 /// @{
682 static bool classof(const IntrinsicInst *I) {
683 return VPCmpIntrinsic::isVPCmp(I->getIntrinsicID());
684 }
685 static bool classof(const Value *V) {
686 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
687 }
688 /// @}
689};
690
692public:
693 static bool isVPBinOp(Intrinsic::ID ID);
694
695 /// Methods for support type inquiry through isa, cast, and dyn_cast:
696 /// @{
697 static bool classof(const IntrinsicInst *I) {
698 return VPBinOpIntrinsic::isVPBinOp(I->getIntrinsicID());
699 }
700 static bool classof(const Value *V) {
701 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
702 }
703 /// @}
704};
705
706
707/// This is the common base class for constrained floating point intrinsics.
709public:
710 bool isUnaryOp() const;
711 bool isTernaryOp() const;
712 std::optional<RoundingMode> getRoundingMode() const;
713 std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
714 bool isDefaultFPEnvironment() const;
715
716 // Methods for support type inquiry through isa, cast, and dyn_cast:
717 static bool classof(const IntrinsicInst *I);
718 static bool classof(const Value *V) {
719 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
720 }
721};
722
723/// Constrained floating point compare intrinsics.
725public:
727 bool isSignaling() const {
728 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
729 }
730
731 // Methods for support type inquiry through isa, cast, and dyn_cast:
732 static bool classof(const IntrinsicInst *I) {
733 switch (I->getIntrinsicID()) {
734 case Intrinsic::experimental_constrained_fcmp:
735 case Intrinsic::experimental_constrained_fcmps:
736 return true;
737 default:
738 return false;
739 }
740 }
741 static bool classof(const Value *V) {
742 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
743 }
744};
745
746/// This class represents min/max intrinsics.
748public:
749 static bool classof(const IntrinsicInst *I) {
750 switch (I->getIntrinsicID()) {
751 case Intrinsic::umin:
752 case Intrinsic::umax:
753 case Intrinsic::smin:
754 case Intrinsic::smax:
755 return true;
756 default:
757 return false;
758 }
759 }
760 static bool classof(const Value *V) {
761 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
762 }
763
764 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
765 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
766
767 /// Returns the comparison predicate underlying the intrinsic.
769 switch (ID) {
770 case Intrinsic::umin:
772 case Intrinsic::umax:
774 case Intrinsic::smin:
776 case Intrinsic::smax:
778 default:
779 llvm_unreachable("Invalid intrinsic");
780 }
781 }
782
783 /// Returns the comparison predicate underlying the intrinsic.
786 }
787
788 /// Whether the intrinsic is signed or unsigned.
789 static bool isSigned(Intrinsic::ID ID) {
791 };
792
793 /// Whether the intrinsic is signed or unsigned.
794 bool isSigned() const { return isSigned(getIntrinsicID()); };
795
796 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
797 /// so there is a certain threshold value, upon reaching which,
798 /// their value can no longer change. Return said threshold.
799 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
800 switch (ID) {
801 case Intrinsic::umin:
802 return APInt::getMinValue(numBits);
803 case Intrinsic::umax:
804 return APInt::getMaxValue(numBits);
805 case Intrinsic::smin:
806 return APInt::getSignedMinValue(numBits);
807 case Intrinsic::smax:
808 return APInt::getSignedMaxValue(numBits);
809 default:
810 llvm_unreachable("Invalid intrinsic");
811 }
812 }
813
814 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
815 /// so there is a certain threshold value, upon reaching which,
816 /// their value can no longer change. Return said threshold.
817 APInt getSaturationPoint(unsigned numBits) const {
818 return getSaturationPoint(getIntrinsicID(), numBits);
819 }
820
821 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
822 /// so there is a certain threshold value, upon reaching which,
823 /// their value can no longer change. Return said threshold.
827 }
828
829 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
830 /// so there is a certain threshold value, upon reaching which,
831 /// their value can no longer change. Return said threshold.
834 }
835};
836
837/// This class represents an intrinsic that is based on a binary operation.
838/// This includes op.with.overflow and saturating add/sub intrinsics.
840public:
841 static bool classof(const IntrinsicInst *I) {
842 switch (I->getIntrinsicID()) {
843 case Intrinsic::uadd_with_overflow:
844 case Intrinsic::sadd_with_overflow:
845 case Intrinsic::usub_with_overflow:
846 case Intrinsic::ssub_with_overflow:
847 case Intrinsic::umul_with_overflow:
848 case Intrinsic::smul_with_overflow:
849 case Intrinsic::uadd_sat:
850 case Intrinsic::sadd_sat:
851 case Intrinsic::usub_sat:
852 case Intrinsic::ssub_sat:
853 return true;
854 default:
855 return false;
856 }
857 }
858 static bool classof(const Value *V) {
859 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
860 }
861
862 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
863 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
864
865 /// Returns the binary operation underlying the intrinsic.
867
868 /// Whether the intrinsic is signed or unsigned.
869 bool isSigned() const;
870
871 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
872 unsigned getNoWrapKind() const;
873};
874
875/// Represents an op.with.overflow intrinsic.
877public:
878 static bool classof(const IntrinsicInst *I) {
879 switch (I->getIntrinsicID()) {
880 case Intrinsic::uadd_with_overflow:
881 case Intrinsic::sadd_with_overflow:
882 case Intrinsic::usub_with_overflow:
883 case Intrinsic::ssub_with_overflow:
884 case Intrinsic::umul_with_overflow:
885 case Intrinsic::smul_with_overflow:
886 return true;
887 default:
888 return false;
889 }
890 }
891 static bool classof(const Value *V) {
892 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
893 }
894};
895
896/// Represents a saturating add/sub intrinsic.
898public:
899 static bool classof(const IntrinsicInst *I) {
900 switch (I->getIntrinsicID()) {
901 case Intrinsic::uadd_sat:
902 case Intrinsic::sadd_sat:
903 case Intrinsic::usub_sat:
904 case Intrinsic::ssub_sat:
905 return true;
906 default:
907 return false;
908 }
909 }
910 static bool classof(const Value *V) {
911 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
912 }
913};
914
915/// Common base class for all memory intrinsics. Simply provides
916/// common methods.
917/// Written as CRTP to avoid a common base class amongst the
918/// three atomicity hierarchies.
919template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
920private:
921 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
922
923public:
924 Value *getRawDest() const {
925 return const_cast<Value *>(getArgOperand(ARG_DEST));
926 }
927 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
928 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
929
930 Value *getLength() const {
931 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
932 }
933 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
934 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
935
936 /// This is just like getRawDest, but it strips off any cast
937 /// instructions (including addrspacecast) that feed it, giving the
938 /// original input. The returned value is guaranteed to be a pointer.
939 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
940
941 unsigned getDestAddressSpace() const {
942 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
943 }
944
945 /// FIXME: Remove this function once transition to Align is over.
946 /// Use getDestAlign() instead.
947 LLVM_DEPRECATED("Use getDestAlign() instead", "getDestAlign")
949 if (auto MA = getParamAlign(ARG_DEST))
950 return MA->value();
951 return 0;
952 }
953 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
954
955 /// Set the specified arguments of the instruction.
957 assert(getRawDest()->getType() == Ptr->getType() &&
958 "setDest called with pointer of wrong type!");
959 setArgOperand(ARG_DEST, Ptr);
960 }
961
962 void setDestAlignment(MaybeAlign Alignment) {
963 removeParamAttr(ARG_DEST, Attribute::Alignment);
964 if (Alignment)
965 addParamAttr(ARG_DEST,
967 }
968 void setDestAlignment(Align Alignment) {
969 removeParamAttr(ARG_DEST, Attribute::Alignment);
970 addParamAttr(ARG_DEST,
972 }
973
974 void setLength(Value *L) {
975 assert(getLength()->getType() == L->getType() &&
976 "setLength called with value of wrong type!");
977 setArgOperand(ARG_LENGTH, L);
978 }
979};
980
981/// Common base class for all memory transfer intrinsics. Simply provides
982/// common methods.
983template <class BaseCL> class MemTransferBase : public BaseCL {
984private:
985 enum { ARG_SOURCE = 1 };
986
987public:
988 /// Return the arguments to the instruction.
990 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
991 }
992 const Use &getRawSourceUse() const {
993 return BaseCL::getArgOperandUse(ARG_SOURCE);
994 }
995 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
996
997 /// This is just like getRawSource, but it strips off any cast
998 /// instructions that feed it, giving the original input. The returned
999 /// value is guaranteed to be a pointer.
1001
1002 unsigned getSourceAddressSpace() const {
1003 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
1004 }
1005
1006 /// FIXME: Remove this function once transition to Align is over.
1007 /// Use getSourceAlign() instead.
1008 LLVM_DEPRECATED("Use getSourceAlign() instead", "getSourceAlign")
1010 if (auto MA = BaseCL::getParamAlign(ARG_SOURCE))
1011 return MA->value();
1012 return 0;
1013 }
1014
1016 return BaseCL::getParamAlign(ARG_SOURCE);
1017 }
1018
1020 assert(getRawSource()->getType() == Ptr->getType() &&
1021 "setSource called with pointer of wrong type!");
1022 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1023 }
1024
1026 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1027 if (Alignment)
1028 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1029 BaseCL::getContext(), *Alignment));
1030 }
1031
1032 void setSourceAlignment(Align Alignment) {
1033 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1034 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1035 BaseCL::getContext(), Alignment));
1036 }
1037};
1038
1039/// Common base class for all memset intrinsics. Simply provides
1040/// common methods.
1041template <class BaseCL> class MemSetBase : public BaseCL {
1042private:
1043 enum { ARG_VALUE = 1 };
1044
1045public:
1046 Value *getValue() const {
1047 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1048 }
1049 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1050 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1051
1052 void setValue(Value *Val) {
1053 assert(getValue()->getType() == Val->getType() &&
1054 "setValue called with value of wrong type!");
1055 BaseCL::setArgOperand(ARG_VALUE, Val);
1056 }
1057};
1058
1059// The common base class for the atomic memset/memmove/memcpy intrinsics
1060// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1061class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
1062private:
1063 enum { ARG_ELEMENTSIZE = 3 };
1064
1065public:
1067 return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
1068 }
1069
1071 return cast<ConstantInt>(getRawElementSizeInBytes());
1072 }
1073
1076 }
1077
1079 assert(V->getType() == Type::getInt8Ty(getContext()) &&
1080 "setElementSizeInBytes called with value of wrong type!");
1081 setArgOperand(ARG_ELEMENTSIZE, V);
1082 }
1083
1084 static bool classof(const IntrinsicInst *I) {
1085 switch (I->getIntrinsicID()) {
1086 case Intrinsic::memcpy_element_unordered_atomic:
1087 case Intrinsic::memmove_element_unordered_atomic:
1088 case Intrinsic::memset_element_unordered_atomic:
1089 return true;
1090 default:
1091 return false;
1092 }
1093 }
1094 static bool classof(const Value *V) {
1095 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1096 }
1097};
1098
1099/// This class represents atomic memset intrinsic
1100// i.e. llvm.element.unordered.atomic.memset
1101class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
1102public:
1103 static bool classof(const IntrinsicInst *I) {
1104 return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
1105 }
1106 static bool classof(const Value *V) {
1107 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1108 }
1109};
1110
1111// This class wraps the atomic memcpy/memmove intrinsics
1112// i.e. llvm.element.unordered.atomic.memcpy/memmove
1113class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
1114public:
1115 static bool classof(const IntrinsicInst *I) {
1116 switch (I->getIntrinsicID()) {
1117 case Intrinsic::memcpy_element_unordered_atomic:
1118 case Intrinsic::memmove_element_unordered_atomic:
1119 return true;
1120 default:
1121 return false;
1122 }
1123 }
1124 static bool classof(const Value *V) {
1125 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1126 }
1127};
1128
1129/// This class represents the atomic memcpy intrinsic
1130/// i.e. llvm.element.unordered.atomic.memcpy
1132public:
1133 static bool classof(const IntrinsicInst *I) {
1134 return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
1135 }
1136 static bool classof(const Value *V) {
1137 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1138 }
1139};
1140
1141/// This class represents the atomic memmove intrinsic
1142/// i.e. llvm.element.unordered.atomic.memmove
1144public:
1145 static bool classof(const IntrinsicInst *I) {
1146 return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
1147 }
1148 static bool classof(const Value *V) {
1149 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1150 }
1151};
1152
1153/// This is the common base class for memset/memcpy/memmove.
1154class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1155private:
1156 enum { ARG_VOLATILE = 3 };
1157
1158public:
1160 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
1161 }
1162
1163 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1164
1165 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1166
1167 // Methods for support type inquiry through isa, cast, and dyn_cast:
1168 static bool classof(const IntrinsicInst *I) {
1169 switch (I->getIntrinsicID()) {
1170 case Intrinsic::memcpy:
1171 case Intrinsic::memmove:
1172 case Intrinsic::memset:
1173 case Intrinsic::memset_inline:
1174 case Intrinsic::memcpy_inline:
1175 return true;
1176 default:
1177 return false;
1178 }
1179 }
1180 static bool classof(const Value *V) {
1181 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1182 }
1183};
1184
1185/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1186class MemSetInst : public MemSetBase<MemIntrinsic> {
1187public:
1188 // Methods for support type inquiry through isa, cast, and dyn_cast:
1189 static bool classof(const IntrinsicInst *I) {
1190 switch (I->getIntrinsicID()) {
1191 case Intrinsic::memset:
1192 case Intrinsic::memset_inline:
1193 return true;
1194 default:
1195 return false;
1196 }
1197 }
1198 static bool classof(const Value *V) {
1199 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1200 }
1201};
1202
1203/// This class wraps the llvm.memset.inline intrinsic.
1205public:
1207 return cast<ConstantInt>(MemSetInst::getLength());
1208 }
1209 // Methods for support type inquiry through isa, cast, and dyn_cast:
1210 static bool classof(const IntrinsicInst *I) {
1211 return I->getIntrinsicID() == Intrinsic::memset_inline;
1212 }
1213 static bool classof(const Value *V) {
1214 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1215 }
1216};
1217
1218/// This class wraps the llvm.memcpy/memmove intrinsics.
1219class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1220public:
1221 // Methods for support type inquiry through isa, cast, and dyn_cast:
1222 static bool classof(const IntrinsicInst *I) {
1223 switch (I->getIntrinsicID()) {
1224 case Intrinsic::memcpy:
1225 case Intrinsic::memmove:
1226 case Intrinsic::memcpy_inline:
1227 return true;
1228 default:
1229 return false;
1230 }
1231 }
1232 static bool classof(const Value *V) {
1233 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1234 }
1235};
1236
1237/// This class wraps the llvm.memcpy intrinsic.
1239public:
1240 // Methods for support type inquiry through isa, cast, and dyn_cast:
1241 static bool classof(const IntrinsicInst *I) {
1242 return I->getIntrinsicID() == Intrinsic::memcpy ||
1243 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1244 }
1245 static bool classof(const Value *V) {
1246 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1247 }
1248};
1249
1250/// This class wraps the llvm.memmove intrinsic.
1252public:
1253 // Methods for support type inquiry through isa, cast, and dyn_cast:
1254 static bool classof(const IntrinsicInst *I) {
1255 return I->getIntrinsicID() == Intrinsic::memmove;
1256 }
1257 static bool classof(const Value *V) {
1258 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1259 }
1260};
1261
1262/// This class wraps the llvm.memcpy.inline intrinsic.
1264public:
1266 return cast<ConstantInt>(MemCpyInst::getLength());
1267 }
1268 // Methods for support type inquiry through isa, cast, and dyn_cast:
1269 static bool classof(const IntrinsicInst *I) {
1270 return I->getIntrinsicID() == Intrinsic::memcpy_inline;
1271 }
1272 static bool classof(const Value *V) {
1273 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1274 }
1275};
1276
1277// The common base class for any memset/memmove/memcpy intrinsics;
1278// whether they be atomic or non-atomic.
1279// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1280// and llvm.memset/memcpy/memmove
1281class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1282public:
1283 bool isVolatile() const {
1284 // Only the non-atomic intrinsics can be volatile
1285 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1286 return MI->isVolatile();
1287 return false;
1288 }
1289
1290 static bool classof(const IntrinsicInst *I) {
1291 switch (I->getIntrinsicID()) {
1292 case Intrinsic::memcpy:
1293 case Intrinsic::memcpy_inline:
1294 case Intrinsic::memmove:
1295 case Intrinsic::memset:
1296 case Intrinsic::memset_inline:
1297 case Intrinsic::memcpy_element_unordered_atomic:
1298 case Intrinsic::memmove_element_unordered_atomic:
1299 case Intrinsic::memset_element_unordered_atomic:
1300 return true;
1301 default:
1302 return false;
1303 }
1304 }
1305 static bool classof(const Value *V) {
1306 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1307 }
1308};
1309
1310/// This class represents any memset intrinsic
1311// i.e. llvm.element.unordered.atomic.memset
1312// and llvm.memset
1313class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1314public:
1315 static bool classof(const IntrinsicInst *I) {
1316 switch (I->getIntrinsicID()) {
1317 case Intrinsic::memset:
1318 case Intrinsic::memset_inline:
1319 case Intrinsic::memset_element_unordered_atomic:
1320 return true;
1321 default:
1322 return false;
1323 }
1324 }
1325 static bool classof(const Value *V) {
1326 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1327 }
1328};
1329
1330// This class wraps any memcpy/memmove intrinsics
1331// i.e. llvm.element.unordered.atomic.memcpy/memmove
1332// and llvm.memcpy/memmove
1333class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1334public:
1335 static bool classof(const IntrinsicInst *I) {
1336 switch (I->getIntrinsicID()) {
1337 case Intrinsic::memcpy:
1338 case Intrinsic::memcpy_inline:
1339 case Intrinsic::memmove:
1340 case Intrinsic::memcpy_element_unordered_atomic:
1341 case Intrinsic::memmove_element_unordered_atomic:
1342 return true;
1343 default:
1344 return false;
1345 }
1346 }
1347 static bool classof(const Value *V) {
1348 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1349 }
1350};
1351
1352/// This class represents any memcpy intrinsic
1353/// i.e. llvm.element.unordered.atomic.memcpy
1354/// and llvm.memcpy
1356public:
1357 static bool classof(const IntrinsicInst *I) {
1358 switch (I->getIntrinsicID()) {
1359 case Intrinsic::memcpy:
1360 case Intrinsic::memcpy_inline:
1361 case Intrinsic::memcpy_element_unordered_atomic:
1362 return true;
1363 default:
1364 return false;
1365 }
1366 }
1367 static bool classof(const Value *V) {
1368 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1369 }
1370};
1371
1372/// This class represents any memmove intrinsic
1373/// i.e. llvm.element.unordered.atomic.memmove
1374/// and llvm.memmove
1376public:
1377 static bool classof(const IntrinsicInst *I) {
1378 switch (I->getIntrinsicID()) {
1379 case Intrinsic::memmove:
1380 case Intrinsic::memmove_element_unordered_atomic:
1381 return true;
1382 default:
1383 return false;
1384 }
1385 }
1386 static bool classof(const Value *V) {
1387 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1388 }
1389};
1390
1391/// This represents the llvm.va_start intrinsic.
1393public:
1394 static bool classof(const IntrinsicInst *I) {
1395 return I->getIntrinsicID() == Intrinsic::vastart;
1396 }
1397 static bool classof(const Value *V) {
1398 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1399 }
1400
1401 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1402};
1403
1404/// This represents the llvm.va_end intrinsic.
1405class VAEndInst : public IntrinsicInst {
1406public:
1407 static bool classof(const IntrinsicInst *I) {
1408 return I->getIntrinsicID() == Intrinsic::vaend;
1409 }
1410 static bool classof(const Value *V) {
1411 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1412 }
1413
1414 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1415};
1416
1417/// This represents the llvm.va_copy intrinsic.
1419public:
1420 static bool classof(const IntrinsicInst *I) {
1421 return I->getIntrinsicID() == Intrinsic::vacopy;
1422 }
1423 static bool classof(const Value *V) {
1424 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1425 }
1426
1427 Value *getDest() const { return const_cast<Value *>(getArgOperand(0)); }
1428 Value *getSrc() const { return const_cast<Value *>(getArgOperand(1)); }
1429};
1430
1431/// A base class for all instrprof intrinsics.
1433protected:
1434 static bool isCounterBase(const IntrinsicInst &I) {
1435 switch (I.getIntrinsicID()) {
1436 case Intrinsic::instrprof_cover:
1437 case Intrinsic::instrprof_increment:
1438 case Intrinsic::instrprof_increment_step:
1439 case Intrinsic::instrprof_callsite:
1440 case Intrinsic::instrprof_timestamp:
1441 case Intrinsic::instrprof_value_profile:
1442 return true;
1443 }
1444 return false;
1445 }
1446 static bool isMCDCBitmapBase(const IntrinsicInst &I) {
1447 switch (I.getIntrinsicID()) {
1448 case Intrinsic::instrprof_mcdc_parameters:
1449 case Intrinsic::instrprof_mcdc_tvbitmap_update:
1450 return true;
1451 }
1452 return false;
1453 }
1454
1455public:
1456 static bool classof(const Value *V) {
1457 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1458 return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr) ||
1459 Instr->getIntrinsicID() ==
1460 Intrinsic::instrprof_mcdc_condbitmap_update;
1461 return false;
1462 }
1463 // The name of the instrumented function.
1465 return cast<GlobalVariable>(
1466 const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
1467 }
1468 // The hash of the CFG for the instrumented function.
1470 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1471 }
1472};
1473
1474/// A base class for all instrprof counter intrinsics.
1476public:
1477 static bool classof(const Value *V) {
1478 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1479 return InstrProfInstBase::isCounterBase(*Instr);
1480 return false;
1481 }
1482
1483 // The number of counters for the instrumented function.
1484 ConstantInt *getNumCounters() const;
1485 // The index of the counter that this instruction acts on.
1486 ConstantInt *getIndex() const;
1487};
1488
1489/// This represents the llvm.instrprof.cover intrinsic.
1491public:
1492 static bool classof(const IntrinsicInst *I) {
1493 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1494 }
1495 static bool classof(const Value *V) {
1496 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1497 }
1498};
1499
1500/// This represents the llvm.instrprof.increment intrinsic.
1502public:
1503 static bool classof(const IntrinsicInst *I) {
1504 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1505 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1506 }
1507 static bool classof(const Value *V) {
1508 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1509 }
1510 Value *getStep() const;
1511};
1512
1513/// This represents the llvm.instrprof.increment.step intrinsic.
1515public:
1516 static bool classof(const IntrinsicInst *I) {
1517 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1518 }
1519 static bool classof(const Value *V) {
1520 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1521 }
1522};
1523
1524/// This represents the llvm.instrprof.callsite intrinsic.
1525/// It is structurally like the increment or step counters, hence the
1526/// inheritance relationship, albeit somewhat tenuous (it's not 'counting' per
1527/// se)
1529public:
1530 static bool classof(const IntrinsicInst *I) {
1531 return I->getIntrinsicID() == Intrinsic::instrprof_callsite;
1532 }
1533 static bool classof(const Value *V) {
1534 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1535 }
1536 Value *getCallee() const;
1537};
1538
1539/// This represents the llvm.instrprof.timestamp intrinsic.
1541public:
1542 static bool classof(const IntrinsicInst *I) {
1543 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1544 }
1545 static bool classof(const Value *V) {
1546 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1547 }
1548};
1549
1550/// This represents the llvm.instrprof.value.profile intrinsic.
1552public:
1553 static bool classof(const IntrinsicInst *I) {
1554 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1555 }
1556 static bool classof(const Value *V) {
1557 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1558 }
1559
1561 return cast<Value>(const_cast<Value *>(getArgOperand(2)));
1562 }
1563
1565 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1566 }
1567
1568 // Returns the value site index.
1570 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
1571 }
1572};
1573
1574/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1576public:
1577 static bool classof(const IntrinsicInst *I) {
1579 }
1580 static bool classof(const Value *V) {
1581 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1582 }
1583
1584 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1585 /// function.
1587 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1588 }
1589};
1590
1591/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1593public:
1594 static bool classof(const IntrinsicInst *I) {
1595 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1596 }
1597 static bool classof(const Value *V) {
1598 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1599 }
1600};
1601
1602/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1604public:
1605 static bool classof(const IntrinsicInst *I) {
1606 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1607 }
1608 static bool classof(const Value *V) {
1609 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1610 }
1611
1612 /// \return The index of the TestVector Bitmap upon which this intrinsic
1613 /// acts.
1615 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1616 }
1617
1618 /// \return The address of the corresponding condition bitmap containing
1619 /// the index of the TestVector to update within the TestVector Bitmap.
1621 return cast<Value>(const_cast<Value *>(getArgOperand(4)));
1622 }
1623};
1624
1625/// This represents the llvm.instrprof.mcdc.condbitmap.update intrinsic.
1626/// It does not pertain to global bitmap updates or parameters and so doesn't
1627/// inherit from InstrProfMCDCBitmapInstBase.
1629public:
1630 static bool classof(const IntrinsicInst *I) {
1631 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_condbitmap_update;
1632 }
1633 static bool classof(const Value *V) {
1634 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1635 }
1636
1637 /// \return The ID of the condition to update.
1639 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1640 }
1641
1642 /// \return The address of the corresponding condition bitmap.
1644 return cast<Value>(const_cast<Value *>(getArgOperand(3)));
1645 }
1646
1647 /// \return The boolean value to set in the condition bitmap for the
1648 /// corresponding condition ID. This represents how the condition evaluated.
1650 return cast<Value>(const_cast<Value *>(getArgOperand(4)));
1651 }
1652};
1653
1655public:
1656 static bool classof(const IntrinsicInst *I) {
1657 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1658 }
1659
1660 static bool classof(const Value *V) {
1661 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1662 }
1663
1665 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(0)));
1666 }
1667
1669 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1670 }
1671
1673 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1674 }
1675
1677 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1678 }
1679};
1680
1682public:
1683 static bool classof(const IntrinsicInst *I) {
1684 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1685 }
1686
1687 static bool classof(const Value *V) {
1688 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1689 }
1690
1692 auto *MV =
1693 cast<MetadataAsValue>(getOperand(Intrinsic::NoAliasScopeDeclScopeArg));
1694 return cast<MDNode>(MV->getMetadata());
1695 }
1696
1697 void setScopeList(MDNode *ScopeList) {
1699 MetadataAsValue::get(getContext(), ScopeList));
1700 }
1701};
1702
1703/// Common base class for representing values projected from a statepoint.
1704/// Currently, the only projections available are gc.result and gc.relocate.
1706public:
1707 static bool classof(const IntrinsicInst *I) {
1708 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1709 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1710 }
1711
1712 static bool classof(const Value *V) {
1713 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1714 }
1715
1716 /// Return true if this relocate is tied to the invoke statepoint.
1717 /// This includes relocates which are on the unwinding path.
1718 bool isTiedToInvoke() const {
1719 const Value *Token = getArgOperand(0);
1720
1721 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1722 }
1723
1724 /// The statepoint with which this gc.relocate is associated.
1725 const Value *getStatepoint() const;
1726};
1727
1728/// Represents calls to the gc.relocate intrinsic.
1730public:
1731 static bool classof(const IntrinsicInst *I) {
1732 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1733 }
1734
1735 static bool classof(const Value *V) {
1736 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1737 }
1738
1739 /// The index into the associate statepoint's argument list
1740 /// which contains the base pointer of the pointer whose
1741 /// relocation this gc.relocate describes.
1742 unsigned getBasePtrIndex() const {
1743 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1744 }
1745
1746 /// The index into the associate statepoint's argument list which
1747 /// contains the pointer whose relocation this gc.relocate describes.
1748 unsigned getDerivedPtrIndex() const {
1749 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1750 }
1751
1752 Value *getBasePtr() const;
1753 Value *getDerivedPtr() const;
1754};
1755
1756/// Represents calls to the gc.result intrinsic.
1758public:
1759 static bool classof(const IntrinsicInst *I) {
1760 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1761 }
1762
1763 static bool classof(const Value *V) {
1764 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1765 }
1766};
1767
1768
1769/// This represents the llvm.assume intrinsic.
1771public:
1772 static bool classof(const IntrinsicInst *I) {
1773 return I->getIntrinsicID() == Intrinsic::assume;
1774 }
1775 static bool classof(const Value *V) {
1776 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1777 }
1778};
1779
1780/// Check if \p ID corresponds to a convergence control intrinsic.
1781static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1782 switch (IntrinsicID) {
1783 default:
1784 return false;
1785 case Intrinsic::experimental_convergence_anchor:
1786 case Intrinsic::experimental_convergence_entry:
1787 case Intrinsic::experimental_convergence_loop:
1788 return true;
1789 }
1790}
1791
1792/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1794public:
1795 static bool classof(const IntrinsicInst *I) {
1796 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1797 }
1798
1799 static bool classof(const Value *V) {
1800 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1801 }
1802
1803 // Returns the convergence intrinsic referenced by |I|'s convergencectrl
1804 // attribute if any.
1806 auto *CI = dyn_cast<llvm::CallInst>(I);
1807 if (!CI)
1808 return nullptr;
1809
1810 auto Bundle = CI->getOperandBundle(llvm::LLVMContext::OB_convergencectrl);
1811 assert(Bundle->Inputs.size() == 1 &&
1812 Bundle->Inputs[0]->getType()->isTokenTy());
1813 return dyn_cast<llvm::IntrinsicInst>(Bundle->Inputs[0].get());
1814 }
1815};
1816
1817} // end namespace llvm
1818
1819#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:194
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:1918
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1742
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: InstrTypes.h:2109
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Definition: InstrTypes.h:1698
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1687
void setArgOperand(unsigned i, Value *v)
Definition: InstrTypes.h:1692
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1871
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:993
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:1022
@ ICMP_UGT
unsigned greater than
Definition: InstrTypes.h:1016
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:1020
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:1018
bool isSigned() const
Definition: InstrTypes.h:1265
This is the shared class of boolean and integer constants.
Definition: Constants.h:80
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Definition: Constants.h:205
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:154
This is an important base class in LLVM.
Definition: Constant.h:41
static Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
Definition: Constants.cpp:400
Constrained floating point compare intrinsics.
FCmpInst::Predicate getPredicate() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This is the common base class for constrained floating point intrinsics.
std::optional< fp::ExceptionBehavior > getExceptionBehavior() const
std::optional< RoundingMode > getRoundingMode() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Represents calls to the llvm.experimintal.convergence.* intrinsics.
static bool classof(const Value *V)
static IntrinsicInst * getParentConvergenceToken(Instruction *I)
static bool classof(const IntrinsicInst *I)
Assignment ID.
DWARF expression.
static std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
This represents the llvm.dbg.assign instruction.
DIAssignID * getAssignID() const
static bool classof(const Value *V)
void setAssignId(DIAssignID *New)
void setKillAddress()
Kill the address component.
bool isKillAddress() const
Check whether this kills the address component.
Metadata * getRawAddress() const
DIExpression * getAddressExpression() const
Value * getAddress() const
static bool classof(const IntrinsicInst *I)
Metadata * getRawAddressExpression() const
Metadata * getRawAssignID() const
void setAddressExpression(DIExpression *NewExpr)
This represents the llvm.dbg.declare instruction.
static bool classof(const Value *V)
Value * getAddress() const
static bool classof(const IntrinsicInst *I)
This is the common base class for debug info intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.dbg.label instruction.
Metadata * getRawLabel() const
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
DILabel * getLabel() const
static bool classof(const Value *V)
void setLabel(DILabel *NewLabel)
This represents the llvm.dbg.value instruction.
iterator_range< location_op_iterator > getValues() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Value * getValue(unsigned OpIdx=0) const
This is the common base class for debug info intrinsics for variables.
DIExpression::FragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
void setVariable(DILocalVariable *NewVar)
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
void setRawLocation(Metadata *Location)
Use of this should generally be avoided; instead, replaceVariableLocationOp and addVariableLocationOp...
void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
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:232
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.callsite intrinsic.
Value * getCallee() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
A base class for all instrprof counter intrinsics.
static bool classof(const Value *V)
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.
static bool classof(const Value *V)
GlobalVariable * getName() const
ConstantInt * getHash() const
static bool isCounterBase(const IntrinsicInst &I)
static bool isMCDCBitmapBase(const IntrinsicInst &I)
A base class for instrprof mcdc intrinsics that require global bitmap bytes.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getNumBitmapBytes() const
This represents the llvm.instrprof.mcdc.parameters intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.mcdc.condbitmap.update intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
ConstantInt * getBitmapIndex() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.instrprof.timestamp intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.value.profile intrinsic.
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
ConstantInt * getValueKind() const
static bool classof(const Value *V)
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:47
bool isAssumeLikeIntrinsic() const
Checks if the intrinsic is an annotation.
static bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
IntrinsicInst(const IntrinsicInst &)=delete
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Definition: IntrinsicInst.h:54
bool isCommutative() const
Return true if swapping the first two arguments to the intrinsic produces the same result.
Definition: IntrinsicInst.h:72
static bool classof(const Value *V)
IntrinsicInst & operator=(const IntrinsicInst &)=delete
static bool classof(const CallInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
bool isAssociative() const
Definition: IntrinsicInst.h:58
This is the common base class for lifetime intrinsics.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Metadata node.
Definition: Metadata.h:1067
LLVMContext & getContext() const
Definition: Metadata.h:1231
This class wraps the llvm.memcpy.inline intrinsic.
static bool classof(const IntrinsicInst *I)
ConstantInt * getLength() const
static bool classof(const Value *V)
This class wraps the llvm.memcpy intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memory intrinsics.
const Use & getRawDestUse() const
Value * getLength() const
Value * getRawDest() const
void setDestAlignment(Align Alignment)
void setLength(Value *L)
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions (including addrspacecast) that ...
void setDestAlignment(MaybeAlign Alignment)
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
unsigned getDestAlignment() const
FIXME: Remove this function once transition to Align is over.
MaybeAlign getDestAlign() const
const Use & getLengthUse() const
unsigned getDestAddressSpace() const
This is the common base class for memset/memcpy/memmove.
ConstantInt * getVolatileCst() const
void setVolatile(Constant *V)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
bool isVolatile() const
This class wraps the llvm.memmove intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memset intrinsics.
void setValue(Value *Val)
const Use & getValueUse() const
Value * getValue() const
This class wraps the llvm.memset.inline intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getLength() const
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memory transfer intrinsics.
unsigned getSourceAlignment() const
FIXME: Remove this function once transition to Align is over.
void setSource(Value *Ptr)
Value * getRawSource() const
Return the arguments to the instruction.
unsigned getSourceAddressSpace() const
MaybeAlign getSourceAlign() const
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it,...
void setSourceAlignment(MaybeAlign Alignment)
void setSourceAlignment(Align Alignment)
const Use & getRawSourceUse() const
This class wraps the llvm.memcpy/memmove intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:103
Root of the metadata hierarchy.
Definition: Metadata.h:62
This class represents min/max intrinsics.
static bool classof(const Value *V)
static Constant * getSaturationPoint(Intrinsic::ID ID, Type *Ty)
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
APInt getSaturationPoint(unsigned numBits) const
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits)
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
Value * getLHS() const
Value * getRHS() const
static ICmpInst::Predicate getPredicate(Intrinsic::ID ID)
Returns the comparison predicate underlying the intrinsic.
ICmpInst::Predicate getPredicate() const
Returns the comparison predicate underlying the intrinsic.
static bool isSigned(Intrinsic::ID ID)
Whether the intrinsic is signed or unsigned.
static bool classof(const IntrinsicInst *I)
bool isSigned() const
Whether the intrinsic is signed or unsigned.
Constant * getSaturationPoint(Type *Ty) const
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
static bool classof(const IntrinsicInst *I)
void setScopeList(MDNode *ScopeList)
static bool classof(const Value *V)
MDNode * getScopeList() const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:118
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1827
ConstantInt * getAttributes() const
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getFactor() const
ConstantInt * getFuncGuid() const
Lightweight class that wraps the location operand metadata of a debug intrinsic.
friend bool operator<=(const RawLocationWrapper &A, const RawLocationWrapper &B)
Metadata * getRawLocation() const
friend bool operator>(const RawLocationWrapper &A, const RawLocationWrapper &B)
RawLocationWrapper(Metadata *RawLocation)
friend bool operator<(const RawLocationWrapper &A, const RawLocationWrapper &B)
friend bool operator==(const RawLocationWrapper &A, const RawLocationWrapper &B)
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
Value * getVariableLocationOp(unsigned OpIdx) const
bool isKillLocation(const DIExpression *Expression) const
friend bool operator!=(const RawLocationWrapper &A, const RawLocationWrapper &B)
unsigned getNumVariableLocationOps() const
friend bool operator>=(const RawLocationWrapper &A, const RawLocationWrapper &B)
Represents a saturating add/sub intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:342
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:427
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static IntegerType * getInt8Ty(LLVMContext &C)
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
Value * getOperand(unsigned i) const
Definition: User.h:169
This represents the llvm.va_copy intrinsic.
Value * getSrc() const
static bool classof(const Value *V)
Value * getDest() const
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_end intrinsic.
Value * getArgList() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_start intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Value * getArgList() const
static bool isVPBinOp(Intrinsic::ID ID)
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
static bool isVPCast(Intrinsic::ID ID)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
static bool isVPCmp(Intrinsic::ID ID)
CmpInst::Predicate getPredicate() const
This is the common base class for vector predication intrinsics.
std::optional< unsigned > getFunctionalIntrinsicID() const
static bool classof(const Value *V)
static Function * getDeclarationForParams(Module *M, Intrinsic::ID, Type *ReturnType, ArrayRef< Value * > Params)
Declares a llvm.vp.
static std::optional< unsigned > getMaskParamPos(Intrinsic::ID IntrinsicID)
bool canIgnoreVectorLengthParam() const
void setMaskParam(Value *)
static std::optional< unsigned > getFunctionalOpcodeForVP(Intrinsic::ID ID)
static std::optional< unsigned > getMemoryDataParamPos(Intrinsic::ID)
Value * getVectorLengthParam() const
static bool classof(const IntrinsicInst *I)
static std::optional< Intrinsic::ID > getFunctionalIntrinsicIDForVP(Intrinsic::ID ID)
void setVectorLengthParam(Value *)
static std::optional< unsigned > getVectorLengthParamPos(Intrinsic::ID IntrinsicID)
static Intrinsic::ID getForOpcode(unsigned OC)
The llvm.vp.* intrinsics for this instruction Opcode.
static std::optional< unsigned > getMemoryPointerParamPos(Intrinsic::ID)
static bool isVPIntrinsic(Intrinsic::ID)
Value * getMemoryDataParam() const
Value * getMemoryPointerParam() const
std::optional< unsigned > getConstrainedIntrinsicID() const
MaybeAlign getPointerAlignment() const
Value * getMaskParam() const
ElementCount getStaticVectorLength() const
static std::optional< Intrinsic::ID > getConstrainedIntrinsicIDForVP(Intrinsic::ID ID)
std::optional< unsigned > getFunctionalOpcode() const
This represents vector predication reduction intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool isVPReduction(Intrinsic::ID ID)
unsigned getStartParamPos() const
unsigned getVectorParamPos() const
Value wrapper in the Metadata hierarchy.
Definition: Metadata.h:450
Value * getValue() const
Definition: Metadata.h:490
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:693
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1074
Represents an op.with.overflow intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:80
A range adaptor for a pair of iterators.
bool operator==(const location_op_iterator &RHS) const
location_op_iterator & operator=(const location_op_iterator &R)
location_op_iterator(ValueAsMetadata **MultiIter)
location_op_iterator(const location_op_iterator &R)
location_op_iterator & operator++()
location_op_iterator(ValueAsMetadata *SingleIter)
location_op_iterator & operator--()
const Value * operator*() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const int NoAliasScopeDeclScopeArg
Definition: Intrinsics.h:37
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1729
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