LLVM 20.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"
37#include <cassert>
38#include <cstdint>
39#include <optional>
40
41namespace llvm {
42
43class Metadata;
44
45/// A wrapper class for inspecting calls to intrinsic functions.
46/// This allows the standard isa/dyncast/cast functionality to work with calls
47/// to intrinsic functions.
48class IntrinsicInst : public CallInst {
49public:
50 IntrinsicInst() = delete;
51 IntrinsicInst(const IntrinsicInst &) = delete;
53
54 /// Return the intrinsic ID of this intrinsic.
57 }
58
59 bool isAssociative() const {
60 switch (getIntrinsicID()) {
61 case Intrinsic::smax:
62 case Intrinsic::smin:
63 case Intrinsic::umax:
64 case Intrinsic::umin:
65 return true;
66 default:
67 return false;
68 }
69 }
70
71 /// Return true if swapping the first two arguments to the intrinsic produces
72 /// the same result.
73 bool isCommutative() const {
74 switch (getIntrinsicID()) {
75 case Intrinsic::maxnum:
76 case Intrinsic::minnum:
77 case Intrinsic::maximum:
78 case Intrinsic::minimum:
79 case Intrinsic::maximumnum:
80 case Intrinsic::minimumnum:
81 case Intrinsic::smax:
82 case Intrinsic::smin:
83 case Intrinsic::umax:
84 case Intrinsic::umin:
85 case Intrinsic::sadd_sat:
86 case Intrinsic::uadd_sat:
87 case Intrinsic::sadd_with_overflow:
88 case Intrinsic::uadd_with_overflow:
89 case Intrinsic::smul_with_overflow:
90 case Intrinsic::umul_with_overflow:
91 case Intrinsic::smul_fix:
92 case Intrinsic::umul_fix:
93 case Intrinsic::smul_fix_sat:
94 case Intrinsic::umul_fix_sat:
95 case Intrinsic::fma:
96 case Intrinsic::fmuladd:
97 return true;
98 default:
99 return false;
100 }
101 }
102
103 /// Checks if the intrinsic is an annotation.
105 switch (getIntrinsicID()) {
106 default: break;
107 case Intrinsic::assume:
108 case Intrinsic::sideeffect:
109 case Intrinsic::pseudoprobe:
110 case Intrinsic::dbg_assign:
111 case Intrinsic::dbg_declare:
112 case Intrinsic::dbg_value:
113 case Intrinsic::dbg_label:
114 case Intrinsic::invariant_start:
115 case Intrinsic::invariant_end:
116 case Intrinsic::lifetime_start:
117 case Intrinsic::lifetime_end:
118 case Intrinsic::experimental_noalias_scope_decl:
119 case Intrinsic::objectsize:
120 case Intrinsic::ptr_annotation:
121 case Intrinsic::var_annotation:
122 return true;
123 }
124 return false;
125 }
126
127 /// Check if the intrinsic might lower into a regular function call in the
128 /// course of IR transformations
129 static bool mayLowerToFunctionCall(Intrinsic::ID IID);
130
131 /// Methods for support type inquiry through isa, cast, and dyn_cast:
132 static bool classof(const CallInst *I) {
133 if (const Function *CF = I->getCalledFunction())
134 return CF->isIntrinsic();
135 return false;
136 }
137 static bool classof(const Value *V) {
138 return isa<CallInst>(V) && classof(cast<CallInst>(V));
139 }
140};
141
142/// Check if \p ID corresponds to a lifetime intrinsic.
144 switch (ID) {
145 case Intrinsic::lifetime_start:
146 case Intrinsic::lifetime_end:
147 return true;
148 default:
149 return false;
150 }
151}
152
153/// This is the common base class for lifetime intrinsics.
155public:
156 /// \name Casting methods
157 /// @{
158 static bool classof(const IntrinsicInst *I) {
159 return isLifetimeIntrinsic(I->getIntrinsicID());
160 }
161 static bool classof(const Value *V) {
162 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
163 }
164 /// @}
165};
166
167/// Check if \p ID corresponds to a debug info intrinsic.
169 switch (ID) {
170 case Intrinsic::dbg_declare:
171 case Intrinsic::dbg_value:
172 case Intrinsic::dbg_label:
173 case Intrinsic::dbg_assign:
174 return true;
175 default:
176 return false;
177 }
178}
179
180/// This is the common base class for debug info intrinsics.
182public:
183 /// \name Casting methods
184 /// @{
185 static bool classof(const IntrinsicInst *I) {
186 return isDbgInfoIntrinsic(I->getIntrinsicID());
187 }
188 static bool classof(const Value *V) {
189 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
190 }
191 /// @}
192};
193
194// Iterator for ValueAsMetadata that internally uses direct pointer iteration
195// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
196// ValueAsMetadata .
198 : public iterator_facade_base<location_op_iterator,
199 std::bidirectional_iterator_tag, Value *> {
201
202public:
203 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
204 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
205
208 I = R.I;
209 return *this;
210 }
211 bool operator==(const location_op_iterator &RHS) const { return I == RHS.I; }
212 const Value *operator*() const {
213 ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
214 ? cast<ValueAsMetadata *>(I)
215 : *cast<ValueAsMetadata **>(I);
216 return VAM->getValue();
217 };
219 ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
220 ? cast<ValueAsMetadata *>(I)
221 : *cast<ValueAsMetadata **>(I);
222 return VAM->getValue();
223 }
225 if (isa<ValueAsMetadata *>(I))
226 I = cast<ValueAsMetadata *>(I) + 1;
227 else
228 I = cast<ValueAsMetadata **>(I) + 1;
229 return *this;
230 }
232 if (isa<ValueAsMetadata *>(I))
233 I = cast<ValueAsMetadata *>(I) - 1;
234 else
235 I = cast<ValueAsMetadata **>(I) - 1;
236 return *this;
237 }
238};
239
240/// Lightweight class that wraps the location operand metadata of a debug
241/// intrinsic. The raw location may be a ValueAsMetadata, an empty MDTuple,
242/// or a DIArgList.
244 Metadata *RawLocation = nullptr;
245
246public:
248 explicit RawLocationWrapper(Metadata *RawLocation)
249 : RawLocation(RawLocation) {
250 // Allow ValueAsMetadata, empty MDTuple, DIArgList.
251 assert(RawLocation && "unexpected null RawLocation");
252 assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
253 (isa<MDNode>(RawLocation) &&
254 !cast<MDNode>(RawLocation)->getNumOperands()));
255 }
256 Metadata *getRawLocation() const { return RawLocation; }
257 /// Get the locations corresponding to the variable referenced by the debug
258 /// info intrinsic. Depending on the intrinsic, this could be the
259 /// variable's value or its address.
261 Value *getVariableLocationOp(unsigned OpIdx) const;
262 unsigned getNumVariableLocationOps() const {
263 if (hasArgList())
264 return cast<DIArgList>(getRawLocation())->getArgs().size();
265 return 1;
266 }
267 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
269 // Check for "kill" sentinel values.
270 // Non-variadic: empty metadata.
271 if (!hasArgList() && isa<MDNode>(getRawLocation()))
272 return true;
273 // Variadic: empty DIArgList with empty expression.
274 if (getNumVariableLocationOps() == 0 && !Expression->isComplex())
275 return true;
276 // Variadic and non-variadic: Interpret expressions using undef or poison
277 // values as kills.
278 return any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
279 }
280
281 friend bool operator==(const RawLocationWrapper &A,
282 const RawLocationWrapper &B) {
283 return A.RawLocation == B.RawLocation;
284 }
285 friend bool operator!=(const RawLocationWrapper &A,
286 const RawLocationWrapper &B) {
287 return !(A == B);
288 }
289 friend bool operator>(const RawLocationWrapper &A,
290 const RawLocationWrapper &B) {
291 return A.RawLocation > B.RawLocation;
292 }
293 friend bool operator>=(const RawLocationWrapper &A,
294 const RawLocationWrapper &B) {
295 return A.RawLocation >= B.RawLocation;
296 }
297 friend bool operator<(const RawLocationWrapper &A,
298 const RawLocationWrapper &B) {
299 return A.RawLocation < B.RawLocation;
300 }
301 friend bool operator<=(const RawLocationWrapper &A,
302 const RawLocationWrapper &B) {
303 return A.RawLocation <= B.RawLocation;
304 }
305};
306
307/// This is the common base class for debug info intrinsics for variables.
309public:
310 /// Get the locations corresponding to the variable referenced by the debug
311 /// info intrinsic. Depending on the intrinsic, this could be the
312 /// variable's value or its address.
314
315 Value *getVariableLocationOp(unsigned OpIdx) const;
316
317 void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
318 bool AllowEmpty = false);
319 void replaceVariableLocationOp(unsigned OpIdx, Value *NewValue);
320 /// Adding a new location operand will always result in this intrinsic using
321 /// an ArgList, and must always be accompanied by a new expression that uses
322 /// the new operand.
325
327 setArgOperand(1, MetadataAsValue::get(NewVar->getContext(), NewVar));
328 }
329
332 }
333
334 unsigned getNumVariableLocationOps() const {
336 }
337
338 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
339
340 /// Does this describe the address of a local variable. True for dbg.declare,
341 /// but not dbg.value, which describes its value, or dbg.assign, which
342 /// describes a combination of the variable's value and address.
343 bool isAddressOfVariable() const {
344 return getIntrinsicID() == Intrinsic::dbg_declare;
345 }
346
347 /// Determine if this describes the value of a local variable. It is true for
348 /// dbg.value, but false for dbg.declare, which describes its address, and
349 /// false for dbg.assign, which describes a combination of the variable's
350 /// value and address.
351 bool isValueOfVariable() const {
352 return getIntrinsicID() == Intrinsic::dbg_value;
353 }
354
356 // TODO: When/if we remove duplicate values from DIArgLists, we don't need
357 // this set anymore.
358 SmallPtrSet<Value *, 4> RemovedValues;
359 for (Value *OldValue : location_ops()) {
360 if (!RemovedValues.insert(OldValue).second)
361 continue;
362 Value *Poison = PoisonValue::get(OldValue->getType());
364 }
365 }
366
367 bool isKillLocation() const {
369 }
370
372 return cast<DILocalVariable>(getRawVariable());
373 }
374
376 return cast<DIExpression>(getRawExpression());
377 }
378
380 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
381 }
382
385 }
386
388 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
389 }
390
392 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
393 }
394
395 /// Use of this should generally be avoided; instead,
396 /// replaceVariableLocationOp and addVariableLocationOps should be used where
397 /// possible to avoid creating invalid state.
398 void setRawLocation(Metadata *Location) {
399 return setArgOperand(0, MetadataAsValue::get(getContext(), Location));
400 }
401
402 /// Get the size (in bits) of the variable, or fragment of the variable that
403 /// is described.
404 std::optional<uint64_t> getFragmentSizeInBits() const;
405
406 /// Get the FragmentInfo for the variable.
407 std::optional<DIExpression::FragmentInfo> getFragment() const {
408 return getExpression()->getFragmentInfo();
409 }
410
411 /// Get the FragmentInfo for the variable if it exists, otherwise return a
412 /// FragmentInfo that covers the entire variable if the variable size is
413 /// known, otherwise return a zero-sized fragment.
415 DIExpression::FragmentInfo VariableSlice(0, 0);
416 // Get the fragment or variable size, or zero.
417 if (auto Sz = getFragmentSizeInBits())
418 VariableSlice.SizeInBits = *Sz;
419 if (auto Frag = getExpression()->getFragmentInfo())
420 VariableSlice.OffsetInBits = Frag->OffsetInBits;
421 return VariableSlice;
422 }
423
424 /// \name Casting methods
425 /// @{
426 static bool classof(const IntrinsicInst *I) {
427 switch (I->getIntrinsicID()) {
428 case Intrinsic::dbg_declare:
429 case Intrinsic::dbg_value:
430 case Intrinsic::dbg_assign:
431 return true;
432 default:
433 return false;
434 }
435 }
436 static bool classof(const Value *V) {
437 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
438 }
439 /// @}
440protected:
441 void setArgOperand(unsigned i, Value *v) {
443 }
444 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
445};
446
447/// This represents the llvm.dbg.declare instruction.
449public:
450 Value *getAddress() const {
452 "dbg.declare must have exactly 1 location operand.");
453 return getVariableLocationOp(0);
454 }
455
456 /// \name Casting methods
457 /// @{
458 static bool classof(const IntrinsicInst *I) {
459 return I->getIntrinsicID() == Intrinsic::dbg_declare;
460 }
461 static bool classof(const Value *V) {
462 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
463 }
464 /// @}
465};
466
467/// This represents the llvm.dbg.value instruction.
469public:
470 // The default argument should only be used in ISel, and the default option
471 // should be removed once ISel support for multiple location ops is complete.
472 Value *getValue(unsigned OpIdx = 0) const {
473 return getVariableLocationOp(OpIdx);
474 }
476 return location_ops();
477 }
478
479 /// \name Casting methods
480 /// @{
481 static bool classof(const IntrinsicInst *I) {
482 return I->getIntrinsicID() == Intrinsic::dbg_value ||
483 I->getIntrinsicID() == Intrinsic::dbg_assign;
484 }
485 static bool classof(const Value *V) {
486 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
487 }
488 /// @}
489};
490
491/// This represents the llvm.dbg.assign instruction.
493 enum Operands {
494 OpValue,
495 OpVar,
496 OpExpr,
497 OpAssignID,
498 OpAddress,
499 OpAddressExpr,
500 };
501
502public:
503 Value *getAddress() const;
505 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
506 }
508 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
509 }
510 DIAssignID *getAssignID() const { return cast<DIAssignID>(getRawAssignID()); }
512 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
513 }
515 return cast<DIExpression>(getRawAddressExpression());
516 }
518 setArgOperand(OpAddressExpr,
519 MetadataAsValue::get(NewExpr->getContext(), NewExpr));
520 }
521 void setAssignId(DIAssignID *New);
522 void setAddress(Value *V);
523 /// Kill the address component.
524 void setKillAddress();
525 /// Check whether this kills the address component. This doesn't take into
526 /// account the position of the intrinsic, therefore a returned value of false
527 /// does not guarentee the address is a valid location for the variable at the
528 /// intrinsic's position in IR.
529 bool isKillAddress() const;
530 void setValue(Value *V);
531 /// \name Casting methods
532 /// @{
533 static bool classof(const IntrinsicInst *I) {
534 return I->getIntrinsicID() == Intrinsic::dbg_assign;
535 }
536 static bool classof(const Value *V) {
537 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
538 }
539 /// @}
540};
541
542/// This represents the llvm.dbg.label instruction.
544public:
545 DILabel *getLabel() const { return cast<DILabel>(getRawLabel()); }
546 void setLabel(DILabel *NewLabel) {
548 }
549
551 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
552 }
553
554 /// Methods for support type inquiry through isa, cast, and dyn_cast:
555 /// @{
556 static bool classof(const IntrinsicInst *I) {
557 return I->getIntrinsicID() == Intrinsic::dbg_label;
558 }
559 static bool classof(const Value *V) {
560 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
561 }
562 /// @}
563};
564
565/// This is the common base class for vector predication intrinsics.
567public:
568 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
569 /// \p Params. Additionally, the load and gather intrinsics require
570 /// \p ReturnType to be specified.
572 Type *ReturnType,
573 ArrayRef<Value *> Params);
574
575 static std::optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
576 static std::optional<unsigned> getVectorLengthParamPos(
577 Intrinsic::ID IntrinsicID);
578
579 /// The llvm.vp.* intrinsics for this instruction Opcode
580 static Intrinsic::ID getForOpcode(unsigned OC);
581
582 /// The llvm.vp.* intrinsics for this intrinsic ID \p Id. Return \p Id if it
583 /// is already a VP intrinsic.
585
586 // Whether \p ID is a VP intrinsic ID.
587 static bool isVPIntrinsic(Intrinsic::ID);
588
589 /// \return The mask parameter or nullptr.
590 Value *getMaskParam() const;
591 void setMaskParam(Value *);
592
593 /// \return The vector length parameter or nullptr.
596
597 /// \return Whether the vector length param can be ignored.
598 bool canIgnoreVectorLengthParam() const;
599
600 /// \return The static element count (vector number of elements) the vector
601 /// length parameter applies to.
603
604 /// \return The alignment of the pointer used by this load/store/gather or
605 /// scatter.
607 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
608
609 /// \return The pointer operand of this load,store, gather or scatter.
611 static std::optional<unsigned> getMemoryPointerParamPos(Intrinsic::ID);
612
613 /// \return The data (payload) operand of this store or scatter.
614 Value *getMemoryDataParam() const;
615 static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
616
617 // Methods for support type inquiry through isa, cast, and dyn_cast:
618 static bool classof(const IntrinsicInst *I) {
619 return isVPIntrinsic(I->getIntrinsicID());
620 }
621 static bool classof(const Value *V) {
622 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
623 }
624
625 // Equivalent non-predicated opcode
626 std::optional<unsigned> getFunctionalOpcode() const {
628 }
629
630 // Equivalent non-predicated intrinsic ID
631 std::optional<unsigned> getFunctionalIntrinsicID() const {
633 }
634
635 // Equivalent non-predicated constrained ID
636 std::optional<unsigned> getConstrainedIntrinsicID() const {
638 }
639
640 // Equivalent non-predicated opcode
641 static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
642
643 // Equivalent non-predicated intrinsic ID
644 static std::optional<Intrinsic::ID>
646
647 // Equivalent non-predicated constrained ID
648 static std::optional<Intrinsic::ID>
650};
651
652/// This represents vector predication reduction intrinsics.
654public:
655 static bool isVPReduction(Intrinsic::ID ID);
656
657 unsigned getStartParamPos() const;
658 unsigned getVectorParamPos() const;
659
660 static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
661 static std::optional<unsigned> getVectorParamPos(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 VPReductionIntrinsic::isVPReduction(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 isVPCast(Intrinsic::ID ID);
677
678 /// Methods for support type inquiry through isa, cast, and dyn_cast:
679 /// @{
680 static bool classof(const IntrinsicInst *I) {
681 return VPCastIntrinsic::isVPCast(I->getIntrinsicID());
682 }
683 static bool classof(const Value *V) {
684 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
685 }
686 /// @}
687};
688
690public:
691 static bool isVPCmp(Intrinsic::ID ID);
692
694
695 /// Methods for support type inquiry through isa, cast, and dyn_cast:
696 /// @{
697 static bool classof(const IntrinsicInst *I) {
698 return VPCmpIntrinsic::isVPCmp(I->getIntrinsicID());
699 }
700 static bool classof(const Value *V) {
701 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
702 }
703 /// @}
704};
705
707public:
708 static bool isVPBinOp(Intrinsic::ID ID);
709
710 /// Methods for support type inquiry through isa, cast, and dyn_cast:
711 /// @{
712 static bool classof(const IntrinsicInst *I) {
713 return VPBinOpIntrinsic::isVPBinOp(I->getIntrinsicID());
714 }
715 static bool classof(const Value *V) {
716 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
717 }
718 /// @}
719};
720
721
722/// This is the common base class for constrained floating point intrinsics.
724public:
725 unsigned getNonMetadataArgCount() const;
726 std::optional<RoundingMode> getRoundingMode() const;
727 std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
728 bool isDefaultFPEnvironment() const;
729
730 // Methods for support type inquiry through isa, cast, and dyn_cast:
731 static bool classof(const IntrinsicInst *I);
732 static bool classof(const Value *V) {
733 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
734 }
735};
736
737/// Constrained floating point compare intrinsics.
739public:
741 bool isSignaling() const {
742 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
743 }
744
745 // Methods for support type inquiry through isa, cast, and dyn_cast:
746 static bool classof(const IntrinsicInst *I) {
747 switch (I->getIntrinsicID()) {
748 case Intrinsic::experimental_constrained_fcmp:
749 case Intrinsic::experimental_constrained_fcmps:
750 return true;
751 default:
752 return false;
753 }
754 }
755 static bool classof(const Value *V) {
756 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
757 }
758};
759
760/// This class represents min/max intrinsics.
762public:
763 static bool classof(const IntrinsicInst *I) {
764 switch (I->getIntrinsicID()) {
765 case Intrinsic::umin:
766 case Intrinsic::umax:
767 case Intrinsic::smin:
768 case Intrinsic::smax:
769 return true;
770 default:
771 return false;
772 }
773 }
774 static bool classof(const Value *V) {
775 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
776 }
777
778 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
779 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
780
781 /// Returns the comparison predicate underlying the intrinsic.
783 switch (ID) {
784 case Intrinsic::umin:
786 case Intrinsic::umax:
788 case Intrinsic::smin:
790 case Intrinsic::smax:
792 default:
793 llvm_unreachable("Invalid intrinsic");
794 }
795 }
796
797 /// Returns the comparison predicate underlying the intrinsic.
800 }
801
802 /// Whether the intrinsic is signed or unsigned.
803 static bool isSigned(Intrinsic::ID ID) {
805 };
806
807 /// Whether the intrinsic is signed or unsigned.
808 bool isSigned() const { return isSigned(getIntrinsicID()); };
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 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
814 switch (ID) {
815 case Intrinsic::umin:
816 return APInt::getMinValue(numBits);
817 case Intrinsic::umax:
818 return APInt::getMaxValue(numBits);
819 case Intrinsic::smin:
820 return APInt::getSignedMinValue(numBits);
821 case Intrinsic::smax:
822 return APInt::getSignedMaxValue(numBits);
823 default:
824 llvm_unreachable("Invalid intrinsic");
825 }
826 }
827
828 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
829 /// so there is a certain threshold value, upon reaching which,
830 /// their value can no longer change. Return said threshold.
831 APInt getSaturationPoint(unsigned numBits) const {
832 return getSaturationPoint(getIntrinsicID(), numBits);
833 }
834
835 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
836 /// so there is a certain threshold value, upon reaching which,
837 /// their value can no longer change. Return said threshold.
841 }
842
843 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
844 /// so there is a certain threshold value, upon reaching which,
845 /// their value can no longer change. Return said threshold.
848 }
849};
850
851/// This class represents a ucmp/scmp intrinsic
853public:
854 static bool classof(const IntrinsicInst *I) {
855 switch (I->getIntrinsicID()) {
856 case Intrinsic::scmp:
857 case Intrinsic::ucmp:
858 return true;
859 default:
860 return false;
861 }
862 }
863 static bool classof(const Value *V) {
864 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
865 }
866
867 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
868 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
869
870 static bool isSigned(Intrinsic::ID ID) { return ID == Intrinsic::scmp; }
871 bool isSigned() const { return isSigned(getIntrinsicID()); }
872
875 }
878 }
879
882 }
885 }
886};
887
888/// This class represents an intrinsic that is based on a binary operation.
889/// This includes op.with.overflow and saturating add/sub intrinsics.
891public:
892 static bool classof(const IntrinsicInst *I) {
893 switch (I->getIntrinsicID()) {
894 case Intrinsic::uadd_with_overflow:
895 case Intrinsic::sadd_with_overflow:
896 case Intrinsic::usub_with_overflow:
897 case Intrinsic::ssub_with_overflow:
898 case Intrinsic::umul_with_overflow:
899 case Intrinsic::smul_with_overflow:
900 case Intrinsic::uadd_sat:
901 case Intrinsic::sadd_sat:
902 case Intrinsic::usub_sat:
903 case Intrinsic::ssub_sat:
904 return true;
905 default:
906 return false;
907 }
908 }
909 static bool classof(const Value *V) {
910 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
911 }
912
913 Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
914 Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
915
916 /// Returns the binary operation underlying the intrinsic.
918
919 /// Whether the intrinsic is signed or unsigned.
920 bool isSigned() const;
921
922 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
923 unsigned getNoWrapKind() const;
924};
925
926/// Represents an op.with.overflow intrinsic.
928public:
929 static bool classof(const IntrinsicInst *I) {
930 switch (I->getIntrinsicID()) {
931 case Intrinsic::uadd_with_overflow:
932 case Intrinsic::sadd_with_overflow:
933 case Intrinsic::usub_with_overflow:
934 case Intrinsic::ssub_with_overflow:
935 case Intrinsic::umul_with_overflow:
936 case Intrinsic::smul_with_overflow:
937 return true;
938 default:
939 return false;
940 }
941 }
942 static bool classof(const Value *V) {
943 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
944 }
945};
946
947/// Represents a saturating add/sub intrinsic.
949public:
950 static bool classof(const IntrinsicInst *I) {
951 switch (I->getIntrinsicID()) {
952 case Intrinsic::uadd_sat:
953 case Intrinsic::sadd_sat:
954 case Intrinsic::usub_sat:
955 case Intrinsic::ssub_sat:
956 return true;
957 default:
958 return false;
959 }
960 }
961 static bool classof(const Value *V) {
962 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
963 }
964};
965
966/// Common base class for all memory intrinsics. Simply provides
967/// common methods.
968/// Written as CRTP to avoid a common base class amongst the
969/// three atomicity hierarchies.
970template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
971private:
972 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
973
974public:
975 Value *getRawDest() const {
976 return const_cast<Value *>(getArgOperand(ARG_DEST));
977 }
978 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
979 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
980
981 Value *getLength() const {
982 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
983 }
984 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
985 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
986
987 /// This is just like getRawDest, but it strips off any cast
988 /// instructions (including addrspacecast) that feed it, giving the
989 /// original input. The returned value is guaranteed to be a pointer.
990 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
991
992 unsigned getDestAddressSpace() const {
993 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
994 }
995
996 /// FIXME: Remove this function once transition to Align is over.
997 /// Use getDestAlign() instead.
998 LLVM_DEPRECATED("Use getDestAlign() instead", "getDestAlign")
1000 if (auto MA = getParamAlign(ARG_DEST))
1001 return MA->value();
1002 return 0;
1003 }
1004 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
1005
1006 /// Set the specified arguments of the instruction.
1008 assert(getRawDest()->getType() == Ptr->getType() &&
1009 "setDest called with pointer of wrong type!");
1010 setArgOperand(ARG_DEST, Ptr);
1011 }
1012
1014 removeParamAttr(ARG_DEST, Attribute::Alignment);
1015 if (Alignment)
1016 addParamAttr(ARG_DEST,
1018 }
1019 void setDestAlignment(Align Alignment) {
1020 removeParamAttr(ARG_DEST, Attribute::Alignment);
1021 addParamAttr(ARG_DEST,
1023 }
1024
1025 void setLength(Value *L) {
1026 assert(getLength()->getType() == L->getType() &&
1027 "setLength called with value of wrong type!");
1028 setArgOperand(ARG_LENGTH, L);
1029 }
1030};
1031
1032/// Common base class for all memory transfer intrinsics. Simply provides
1033/// common methods.
1034template <class BaseCL> class MemTransferBase : public BaseCL {
1035private:
1036 enum { ARG_SOURCE = 1 };
1037
1038public:
1039 /// Return the arguments to the instruction.
1041 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
1042 }
1043 const Use &getRawSourceUse() const {
1044 return BaseCL::getArgOperandUse(ARG_SOURCE);
1045 }
1046 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
1047
1048 /// This is just like getRawSource, but it strips off any cast
1049 /// instructions that feed it, giving the original input. The returned
1050 /// value is guaranteed to be a pointer.
1052
1053 unsigned getSourceAddressSpace() const {
1054 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
1055 }
1056
1057 /// FIXME: Remove this function once transition to Align is over.
1058 /// Use getSourceAlign() instead.
1059 LLVM_DEPRECATED("Use getSourceAlign() instead", "getSourceAlign")
1061 if (auto MA = BaseCL::getParamAlign(ARG_SOURCE))
1062 return MA->value();
1063 return 0;
1064 }
1065
1067 return BaseCL::getParamAlign(ARG_SOURCE);
1068 }
1069
1071 assert(getRawSource()->getType() == Ptr->getType() &&
1072 "setSource called with pointer of wrong type!");
1073 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1074 }
1075
1077 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1078 if (Alignment)
1079 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1080 BaseCL::getContext(), *Alignment));
1081 }
1082
1083 void setSourceAlignment(Align Alignment) {
1084 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1085 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1086 BaseCL::getContext(), Alignment));
1087 }
1088};
1089
1090/// Common base class for all memset intrinsics. Simply provides
1091/// common methods.
1092template <class BaseCL> class MemSetBase : public BaseCL {
1093private:
1094 enum { ARG_VALUE = 1 };
1095
1096public:
1097 Value *getValue() const {
1098 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1099 }
1100 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1101 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1102
1103 void setValue(Value *Val) {
1104 assert(getValue()->getType() == Val->getType() &&
1105 "setValue called with value of wrong type!");
1106 BaseCL::setArgOperand(ARG_VALUE, Val);
1107 }
1108};
1109
1110// The common base class for the atomic memset/memmove/memcpy intrinsics
1111// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1112class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
1113private:
1114 enum { ARG_ELEMENTSIZE = 3 };
1115
1116public:
1118 return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
1119 }
1120
1122 return cast<ConstantInt>(getRawElementSizeInBytes());
1123 }
1124
1127 }
1128
1130 assert(V->getType() == Type::getInt8Ty(getContext()) &&
1131 "setElementSizeInBytes called with value of wrong type!");
1132 setArgOperand(ARG_ELEMENTSIZE, V);
1133 }
1134
1135 static bool classof(const IntrinsicInst *I) {
1136 switch (I->getIntrinsicID()) {
1137 case Intrinsic::memcpy_element_unordered_atomic:
1138 case Intrinsic::memmove_element_unordered_atomic:
1139 case Intrinsic::memset_element_unordered_atomic:
1140 return true;
1141 default:
1142 return false;
1143 }
1144 }
1145 static bool classof(const Value *V) {
1146 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1147 }
1148};
1149
1150/// This class represents atomic memset intrinsic
1151// i.e. llvm.element.unordered.atomic.memset
1152class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
1153public:
1154 static bool classof(const IntrinsicInst *I) {
1155 return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
1156 }
1157 static bool classof(const Value *V) {
1158 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1159 }
1160};
1161
1162// This class wraps the atomic memcpy/memmove intrinsics
1163// i.e. llvm.element.unordered.atomic.memcpy/memmove
1164class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
1165public:
1166 static bool classof(const IntrinsicInst *I) {
1167 switch (I->getIntrinsicID()) {
1168 case Intrinsic::memcpy_element_unordered_atomic:
1169 case Intrinsic::memmove_element_unordered_atomic:
1170 return true;
1171 default:
1172 return false;
1173 }
1174 }
1175 static bool classof(const Value *V) {
1176 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1177 }
1178};
1179
1180/// This class represents the atomic memcpy intrinsic
1181/// i.e. llvm.element.unordered.atomic.memcpy
1183public:
1184 static bool classof(const IntrinsicInst *I) {
1185 return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
1186 }
1187 static bool classof(const Value *V) {
1188 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1189 }
1190};
1191
1192/// This class represents the atomic memmove intrinsic
1193/// i.e. llvm.element.unordered.atomic.memmove
1195public:
1196 static bool classof(const IntrinsicInst *I) {
1197 return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
1198 }
1199 static bool classof(const Value *V) {
1200 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1201 }
1202};
1203
1204/// This is the common base class for memset/memcpy/memmove.
1205class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1206private:
1207 enum { ARG_VOLATILE = 3 };
1208
1209public:
1211 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
1212 }
1213
1214 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1215
1216 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1217
1218 // Methods for support type inquiry through isa, cast, and dyn_cast:
1219 static bool classof(const IntrinsicInst *I) {
1220 switch (I->getIntrinsicID()) {
1221 case Intrinsic::memcpy:
1222 case Intrinsic::memmove:
1223 case Intrinsic::memset:
1224 case Intrinsic::memset_inline:
1225 case Intrinsic::memcpy_inline:
1226 return true;
1227 default:
1228 return false;
1229 }
1230 }
1231 static bool classof(const Value *V) {
1232 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1233 }
1234};
1235
1236/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1237class MemSetInst : public MemSetBase<MemIntrinsic> {
1238public:
1239 // Methods for support type inquiry through isa, cast, and dyn_cast:
1240 static bool classof(const IntrinsicInst *I) {
1241 switch (I->getIntrinsicID()) {
1242 case Intrinsic::memset:
1243 case Intrinsic::memset_inline:
1244 return true;
1245 default:
1246 return false;
1247 }
1248 }
1249 static bool classof(const Value *V) {
1250 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1251 }
1252};
1253
1254/// This class wraps the llvm.memset.inline intrinsic.
1256public:
1257 // Methods for support type inquiry through isa, cast, and dyn_cast:
1258 static bool classof(const IntrinsicInst *I) {
1259 return I->getIntrinsicID() == Intrinsic::memset_inline;
1260 }
1261 static bool classof(const Value *V) {
1262 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1263 }
1264};
1265
1266/// This class wraps the llvm.memcpy/memmove intrinsics.
1267class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1268public:
1269 // Methods for support type inquiry through isa, cast, and dyn_cast:
1270 static bool classof(const IntrinsicInst *I) {
1271 switch (I->getIntrinsicID()) {
1272 case Intrinsic::memcpy:
1273 case Intrinsic::memmove:
1274 case Intrinsic::memcpy_inline:
1275 return true;
1276 default:
1277 return false;
1278 }
1279 }
1280 static bool classof(const Value *V) {
1281 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1282 }
1283};
1284
1285/// This class wraps the llvm.memcpy intrinsic.
1287public:
1288 // Methods for support type inquiry through isa, cast, and dyn_cast:
1289 static bool classof(const IntrinsicInst *I) {
1290 return I->getIntrinsicID() == Intrinsic::memcpy ||
1291 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1292 }
1293 static bool classof(const Value *V) {
1294 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1295 }
1296};
1297
1298/// This class wraps the llvm.memmove intrinsic.
1300public:
1301 // Methods for support type inquiry through isa, cast, and dyn_cast:
1302 static bool classof(const IntrinsicInst *I) {
1303 return I->getIntrinsicID() == Intrinsic::memmove;
1304 }
1305 static bool classof(const Value *V) {
1306 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1307 }
1308};
1309
1310/// This class wraps the llvm.memcpy.inline intrinsic.
1312public:
1313 // Methods for support type inquiry through isa, cast, and dyn_cast:
1314 static bool classof(const IntrinsicInst *I) {
1315 return I->getIntrinsicID() == Intrinsic::memcpy_inline;
1316 }
1317 static bool classof(const Value *V) {
1318 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1319 }
1320};
1321
1322// The common base class for any memset/memmove/memcpy intrinsics;
1323// whether they be atomic or non-atomic.
1324// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1325// and llvm.memset/memcpy/memmove
1326class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1327public:
1328 bool isVolatile() const {
1329 // Only the non-atomic intrinsics can be volatile
1330 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1331 return MI->isVolatile();
1332 return false;
1333 }
1334
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::memset:
1341 case Intrinsic::memset_inline:
1342 case Intrinsic::memcpy_element_unordered_atomic:
1343 case Intrinsic::memmove_element_unordered_atomic:
1344 case Intrinsic::memset_element_unordered_atomic:
1345 return true;
1346 default:
1347 return false;
1348 }
1349 }
1350 static bool classof(const Value *V) {
1351 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1352 }
1353};
1354
1355/// This class represents any memset intrinsic
1356// i.e. llvm.element.unordered.atomic.memset
1357// and llvm.memset
1358class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1359public:
1360 static bool classof(const IntrinsicInst *I) {
1361 switch (I->getIntrinsicID()) {
1362 case Intrinsic::memset:
1363 case Intrinsic::memset_inline:
1364 case Intrinsic::memset_element_unordered_atomic:
1365 return true;
1366 default:
1367 return false;
1368 }
1369 }
1370 static bool classof(const Value *V) {
1371 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1372 }
1373};
1374
1375// This class wraps any memcpy/memmove intrinsics
1376// i.e. llvm.element.unordered.atomic.memcpy/memmove
1377// and llvm.memcpy/memmove
1378class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1379public:
1380 static bool classof(const IntrinsicInst *I) {
1381 switch (I->getIntrinsicID()) {
1382 case Intrinsic::memcpy:
1383 case Intrinsic::memcpy_inline:
1384 case Intrinsic::memmove:
1385 case Intrinsic::memcpy_element_unordered_atomic:
1386 case Intrinsic::memmove_element_unordered_atomic:
1387 return true;
1388 default:
1389 return false;
1390 }
1391 }
1392 static bool classof(const Value *V) {
1393 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1394 }
1395};
1396
1397/// This class represents any memcpy intrinsic
1398/// i.e. llvm.element.unordered.atomic.memcpy
1399/// and llvm.memcpy
1401public:
1402 static bool classof(const IntrinsicInst *I) {
1403 switch (I->getIntrinsicID()) {
1404 case Intrinsic::memcpy:
1405 case Intrinsic::memcpy_inline:
1406 case Intrinsic::memcpy_element_unordered_atomic:
1407 return true;
1408 default:
1409 return false;
1410 }
1411 }
1412 static bool classof(const Value *V) {
1413 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1414 }
1415};
1416
1417/// This class represents any memmove intrinsic
1418/// i.e. llvm.element.unordered.atomic.memmove
1419/// and llvm.memmove
1421public:
1422 static bool classof(const IntrinsicInst *I) {
1423 switch (I->getIntrinsicID()) {
1424 case Intrinsic::memmove:
1425 case Intrinsic::memmove_element_unordered_atomic:
1426 return true;
1427 default:
1428 return false;
1429 }
1430 }
1431 static bool classof(const Value *V) {
1432 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1433 }
1434};
1435
1436/// This represents the llvm.va_start intrinsic.
1438public:
1439 static bool classof(const IntrinsicInst *I) {
1440 return I->getIntrinsicID() == Intrinsic::vastart;
1441 }
1442 static bool classof(const Value *V) {
1443 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1444 }
1445
1446 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1447};
1448
1449/// This represents the llvm.va_end intrinsic.
1450class VAEndInst : public IntrinsicInst {
1451public:
1452 static bool classof(const IntrinsicInst *I) {
1453 return I->getIntrinsicID() == Intrinsic::vaend;
1454 }
1455 static bool classof(const Value *V) {
1456 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1457 }
1458
1459 Value *getArgList() const { return const_cast<Value *>(getArgOperand(0)); }
1460};
1461
1462/// This represents the llvm.va_copy intrinsic.
1464public:
1465 static bool classof(const IntrinsicInst *I) {
1466 return I->getIntrinsicID() == Intrinsic::vacopy;
1467 }
1468 static bool classof(const Value *V) {
1469 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1470 }
1471
1472 Value *getDest() const { return const_cast<Value *>(getArgOperand(0)); }
1473 Value *getSrc() const { return const_cast<Value *>(getArgOperand(1)); }
1474};
1475
1476/// A base class for all instrprof intrinsics.
1478protected:
1479 static bool isCounterBase(const IntrinsicInst &I) {
1480 switch (I.getIntrinsicID()) {
1481 case Intrinsic::instrprof_cover:
1482 case Intrinsic::instrprof_increment:
1483 case Intrinsic::instrprof_increment_step:
1484 case Intrinsic::instrprof_callsite:
1485 case Intrinsic::instrprof_timestamp:
1486 case Intrinsic::instrprof_value_profile:
1487 return true;
1488 }
1489 return false;
1490 }
1491 static bool isMCDCBitmapBase(const IntrinsicInst &I) {
1492 switch (I.getIntrinsicID()) {
1493 case Intrinsic::instrprof_mcdc_parameters:
1494 case Intrinsic::instrprof_mcdc_tvbitmap_update:
1495 return true;
1496 }
1497 return false;
1498 }
1499
1500public:
1501 static bool classof(const Value *V) {
1502 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1503 return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr);
1504 return false;
1505 }
1506 // The name of the instrumented function.
1508 return cast<GlobalVariable>(
1509 const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
1510 }
1511 // The hash of the CFG for the instrumented function.
1513 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1514 }
1515};
1516
1517/// A base class for all instrprof counter intrinsics.
1519public:
1520 static bool classof(const Value *V) {
1521 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1522 return InstrProfInstBase::isCounterBase(*Instr);
1523 return false;
1524 }
1525
1526 // The number of counters for the instrumented function.
1527 ConstantInt *getNumCounters() const;
1528 // The index of the counter that this instruction acts on.
1529 ConstantInt *getIndex() const;
1530};
1531
1532/// This represents the llvm.instrprof.cover intrinsic.
1534public:
1535 static bool classof(const IntrinsicInst *I) {
1536 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1537 }
1538 static bool classof(const Value *V) {
1539 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1540 }
1541};
1542
1543/// This represents the llvm.instrprof.increment intrinsic.
1545public:
1546 static bool classof(const IntrinsicInst *I) {
1547 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1548 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1549 }
1550 static bool classof(const Value *V) {
1551 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1552 }
1553 Value *getStep() const;
1554};
1555
1556/// This represents the llvm.instrprof.increment.step intrinsic.
1558public:
1559 static bool classof(const IntrinsicInst *I) {
1560 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1561 }
1562 static bool classof(const Value *V) {
1563 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1564 }
1565};
1566
1567/// This represents the llvm.instrprof.callsite intrinsic.
1568/// It is structurally like the increment or step counters, hence the
1569/// inheritance relationship, albeit somewhat tenuous (it's not 'counting' per
1570/// se)
1572public:
1573 static bool classof(const IntrinsicInst *I) {
1574 return I->getIntrinsicID() == Intrinsic::instrprof_callsite;
1575 }
1576 static bool classof(const Value *V) {
1577 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1578 }
1579 Value *getCallee() const;
1580};
1581
1582/// This represents the llvm.instrprof.timestamp intrinsic.
1584public:
1585 static bool classof(const IntrinsicInst *I) {
1586 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1587 }
1588 static bool classof(const Value *V) {
1589 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1590 }
1591};
1592
1593/// This represents the llvm.instrprof.value.profile intrinsic.
1595public:
1596 static bool classof(const IntrinsicInst *I) {
1597 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1598 }
1599 static bool classof(const Value *V) {
1600 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1601 }
1602
1604 return cast<Value>(const_cast<Value *>(getArgOperand(2)));
1605 }
1606
1608 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1609 }
1610
1611 // Returns the value site index.
1613 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
1614 }
1615};
1616
1617/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1619public:
1620 static bool classof(const IntrinsicInst *I) {
1622 }
1623 static bool classof(const Value *V) {
1624 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1625 }
1626
1627 /// \return The number of bits used for the MCDC bitmaps for the instrumented
1628 /// function.
1630 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1631 }
1632
1633 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1634 /// function.
1635 auto getNumBitmapBytes() const {
1636 return alignTo(getNumBitmapBits()->getZExtValue(), CHAR_BIT) / CHAR_BIT;
1637 }
1638};
1639
1640/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1642public:
1643 static bool classof(const IntrinsicInst *I) {
1644 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1645 }
1646 static bool classof(const Value *V) {
1647 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1648 }
1649};
1650
1651/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1653public:
1654 static bool classof(const IntrinsicInst *I) {
1655 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1656 }
1657 static bool classof(const Value *V) {
1658 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1659 }
1660
1661 /// \return The index of the TestVector Bitmap upon which this intrinsic
1662 /// acts.
1664 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1665 }
1666
1667 /// \return The address of the corresponding condition bitmap containing
1668 /// the index of the TestVector to update within the TestVector Bitmap.
1670 return cast<Value>(const_cast<Value *>(getArgOperand(3)));
1671 }
1672};
1673
1675public:
1676 static bool classof(const IntrinsicInst *I) {
1677 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1678 }
1679
1680 static bool classof(const Value *V) {
1681 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1682 }
1683
1685 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(0)));
1686 }
1687
1689 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
1690 }
1691
1693 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
1694 }
1695
1697 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
1698 }
1699};
1700
1702public:
1703 static bool classof(const IntrinsicInst *I) {
1704 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1705 }
1706
1707 static bool classof(const Value *V) {
1708 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1709 }
1710
1712 auto *MV =
1713 cast<MetadataAsValue>(getOperand(Intrinsic::NoAliasScopeDeclScopeArg));
1714 return cast<MDNode>(MV->getMetadata());
1715 }
1716
1717 void setScopeList(MDNode *ScopeList) {
1719 MetadataAsValue::get(getContext(), ScopeList));
1720 }
1721};
1722
1723/// Common base class for representing values projected from a statepoint.
1724/// Currently, the only projections available are gc.result and gc.relocate.
1726public:
1727 static bool classof(const IntrinsicInst *I) {
1728 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1729 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1730 }
1731
1732 static bool classof(const Value *V) {
1733 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1734 }
1735
1736 /// Return true if this relocate is tied to the invoke statepoint.
1737 /// This includes relocates which are on the unwinding path.
1738 bool isTiedToInvoke() const {
1739 const Value *Token = getArgOperand(0);
1740
1741 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1742 }
1743
1744 /// The statepoint with which this gc.relocate is associated.
1745 const Value *getStatepoint() const;
1746};
1747
1748/// Represents calls to the gc.relocate intrinsic.
1750public:
1751 static bool classof(const IntrinsicInst *I) {
1752 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1753 }
1754
1755 static bool classof(const Value *V) {
1756 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1757 }
1758
1759 /// The index into the associate statepoint's argument list
1760 /// which contains the base pointer of the pointer whose
1761 /// relocation this gc.relocate describes.
1762 unsigned getBasePtrIndex() const {
1763 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1764 }
1765
1766 /// The index into the associate statepoint's argument list which
1767 /// contains the pointer whose relocation this gc.relocate describes.
1768 unsigned getDerivedPtrIndex() const {
1769 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1770 }
1771
1772 Value *getBasePtr() const;
1773 Value *getDerivedPtr() const;
1774};
1775
1776/// Represents calls to the gc.result intrinsic.
1778public:
1779 static bool classof(const IntrinsicInst *I) {
1780 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1781 }
1782
1783 static bool classof(const Value *V) {
1784 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1785 }
1786};
1787
1788
1789/// This represents the llvm.assume intrinsic.
1791public:
1792 static bool classof(const IntrinsicInst *I) {
1793 return I->getIntrinsicID() == Intrinsic::assume;
1794 }
1795 static bool classof(const Value *V) {
1796 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1797 }
1798};
1799
1800/// Check if \p ID corresponds to a convergence control intrinsic.
1801static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1802 switch (IntrinsicID) {
1803 default:
1804 return false;
1805 case Intrinsic::experimental_convergence_anchor:
1806 case Intrinsic::experimental_convergence_entry:
1807 case Intrinsic::experimental_convergence_loop:
1808 return true;
1809 }
1810}
1811
1812/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1814public:
1815 static bool classof(const IntrinsicInst *I) {
1816 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1817 }
1818
1819 static bool classof(const Value *V) {
1820 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
1821 }
1822
1823 bool isAnchor() {
1824 return getIntrinsicID() == Intrinsic::experimental_convergence_anchor;
1825 }
1826 bool isEntry() {
1827 return getIntrinsicID() == Intrinsic::experimental_convergence_entry;
1828 }
1829 bool isLoop() {
1830 return getIntrinsicID() == Intrinsic::experimental_convergence_loop;
1831 }
1832};
1833
1834} // end namespace llvm
1835
1836#endif // LLVM_IR_INTRINSICINST_H
@ Poison
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:153
This file contains the declarations for the subclasses of Constant, which represent the different fla...
dxil translate DXIL Translate Metadata
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:77
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
Definition: APInt.h:183
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
Definition: APInt.h:186
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
Definition: APInt.h:193
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Definition: APInt.h:196
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:233
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:1641
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1465
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: InstrTypes.h:1838
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Definition: InstrTypes.h:1421
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1410
void setArgOperand(unsigned i, Value *v)
Definition: InstrTypes.h:1415
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1594
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:757
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:786
@ ICMP_UGT
unsigned greater than
Definition: InstrTypes.h:780
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:784
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:782
bool isSigned() const
Definition: InstrTypes.h:1007
This class represents a ucmp/scmp intrinsic.
static CmpInst::Predicate getGTPredicate(Intrinsic::ID ID)
Value * getRHS() const
CmpInst::Predicate getLTPredicate() const
static CmpInst::Predicate getLTPredicate(Intrinsic::ID ID)
static bool classof(const IntrinsicInst *I)
static bool isSigned(Intrinsic::ID ID)
bool isSigned() const
CmpInst::Predicate getGTPredicate() const
Value * getLHS() const
static bool classof(const Value *V)
This is the shared class of boolean and integer constants.
Definition: Constants.h:81
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Definition: Constants.h:206
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:155
This is an important base class in LLVM.
Definition: Constant.h:42
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
unsigned getNonMetadataArgCount() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Represents calls to the llvm.experimintal.convergence.* intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Assignment ID.
DWARF expression.
static std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
This represents the llvm.dbg.assign instruction.
DIAssignID * getAssignID() const
static bool classof(const Value *V)
void setAssignId(DIAssignID *New)
void setKillAddress()
Kill the address component.
bool isKillAddress() const
Check whether this kills the address component.
Metadata * getRawAddress() const
DIExpression * getAddressExpression() const
Value * getAddress() const
static bool classof(const IntrinsicInst *I)
Metadata * getRawAddressExpression() const
Metadata * getRawAssignID() const
void setAddressExpression(DIExpression *NewExpr)
This represents the llvm.dbg.declare instruction.
static bool classof(const Value *V)
Value * getAddress() const
static bool classof(const IntrinsicInst *I)
This is the common base class for debug info intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.dbg.label instruction.
Metadata * getRawLabel() const
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
DILabel * getLabel() const
static bool classof(const Value *V)
void setLabel(DILabel *NewLabel)
This represents the llvm.dbg.value instruction.
iterator_range< location_op_iterator > getValues() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Value * getValue(unsigned OpIdx=0) const
This is the common base class for debug info intrinsics for variables.
DIExpression::FragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
void setVariable(DILocalVariable *NewVar)
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
void addVariableLocationOps(ArrayRef< Value * > NewValues, DIExpression *NewExpr)
Adding a new location operand will always result in this intrinsic using an ArgList,...
bool isValueOfVariable() const
Determine if this describes the value of a local variable.
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:249
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.
ConstantInt * getNumBitmapBits() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
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.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:48
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:55
bool isCommutative() const
Return true if swapping the first two arguments to the intrinsic produces the same result.
Definition: IntrinsicInst.h:73
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:59
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:1069
LLVMContext & getContext() const
Definition: Metadata.h:1233
This class wraps the llvm.memcpy.inline intrinsic.
static bool classof(const IntrinsicInst *I)
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)
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:1852
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:367
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:502
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
static Intrinsic::ID getForIntrinsic(Intrinsic::ID Id)
The llvm.vp.
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:694
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1075
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.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:155
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
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117