Recommit [NFC] Better encapsulation of llvm::Optional Storage
[llvm-complete.git] / include / llvm / IR / IntrinsicInst.h
blob62bb4fa61d7e99256d8df8428f35b1d83b61274e
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:
13 // if (MemCpyInst *MCI = dyn_cast<MemCpyInst>(Inst))
14 // ... MCI->getDest() ... MCI->getSource() ...
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.
21 //===----------------------------------------------------------------------===//
23 #ifndef LLVM_IR_INTRINSICINST_H
24 #define LLVM_IR_INTRINSICINST_H
26 #include "llvm/IR/Constants.h"
27 #include "llvm/IR/DerivedTypes.h"
28 #include "llvm/IR/Function.h"
29 #include "llvm/IR/GlobalVariable.h"
30 #include "llvm/IR/Instructions.h"
31 #include "llvm/IR/Intrinsics.h"
32 #include "llvm/IR/Metadata.h"
33 #include "llvm/IR/Value.h"
34 #include "llvm/Support/Casting.h"
35 #include <cassert>
36 #include <cstdint>
38 namespace llvm {
40 /// A wrapper class for inspecting calls to intrinsic functions.
41 /// This allows the standard isa/dyncast/cast functionality to work with calls
42 /// to intrinsic functions.
43 class IntrinsicInst : public CallInst {
44 public:
45 IntrinsicInst() = delete;
46 IntrinsicInst(const IntrinsicInst &) = delete;
47 IntrinsicInst &operator=(const IntrinsicInst &) = delete;
49 /// Return the intrinsic ID of this intrinsic.
50 Intrinsic::ID getIntrinsicID() const {
51 return getCalledFunction()->getIntrinsicID();
54 // Methods for support type inquiry through isa, cast, and dyn_cast:
55 static bool classof(const CallInst *I) {
56 if (const Function *CF = I->getCalledFunction())
57 return CF->isIntrinsic();
58 return false;
60 static bool classof(const Value *V) {
61 return isa<CallInst>(V) && classof(cast<CallInst>(V));
65 /// This is the common base class for debug info intrinsics.
66 class DbgInfoIntrinsic : public IntrinsicInst {
67 public:
68 /// \name Casting methods
69 /// @{
70 static bool classof(const IntrinsicInst *I) {
71 switch (I->getIntrinsicID()) {
72 case Intrinsic::dbg_declare:
73 case Intrinsic::dbg_value:
74 case Intrinsic::dbg_addr:
75 case Intrinsic::dbg_label:
76 return true;
77 default: return false;
80 static bool classof(const Value *V) {
81 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
83 /// @}
86 /// This is the common base class for debug info intrinsics for variables.
87 class DbgVariableIntrinsic : public DbgInfoIntrinsic {
88 public:
89 /// Get the location corresponding to the variable referenced by the debug
90 /// info intrinsic. Depending on the intrinsic, this could be the
91 /// variable's value or its address.
92 Value *getVariableLocation(bool AllowNullOp = true) const;
94 /// Does this describe the address of a local variable. True for dbg.addr
95 /// and dbg.declare, but not dbg.value, which describes its value.
96 bool isAddressOfVariable() const {
97 return getIntrinsicID() != Intrinsic::dbg_value;
100 DILocalVariable *getVariable() const {
101 return cast<DILocalVariable>(getRawVariable());
104 DIExpression *getExpression() const {
105 return cast<DIExpression>(getRawExpression());
108 Metadata *getRawVariable() const {
109 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
112 Metadata *getRawExpression() const {
113 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
116 /// Get the size (in bits) of the variable, or fragment of the variable that
117 /// is described.
118 Optional<uint64_t> getFragmentSizeInBits() const;
120 /// \name Casting methods
121 /// @{
122 static bool classof(const IntrinsicInst *I) {
123 switch (I->getIntrinsicID()) {
124 case Intrinsic::dbg_declare:
125 case Intrinsic::dbg_value:
126 case Intrinsic::dbg_addr:
127 return true;
128 default: return false;
131 static bool classof(const Value *V) {
132 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
134 /// @}
137 /// This represents the llvm.dbg.declare instruction.
138 class DbgDeclareInst : public DbgVariableIntrinsic {
139 public:
140 Value *getAddress() const { return getVariableLocation(); }
142 /// \name Casting methods
143 /// @{
144 static bool classof(const IntrinsicInst *I) {
145 return I->getIntrinsicID() == Intrinsic::dbg_declare;
147 static bool classof(const Value *V) {
148 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
150 /// @}
153 /// This represents the llvm.dbg.addr instruction.
154 class DbgAddrIntrinsic : public DbgVariableIntrinsic {
155 public:
156 Value *getAddress() const { return getVariableLocation(); }
158 /// \name Casting methods
159 /// @{
160 static bool classof(const IntrinsicInst *I) {
161 return I->getIntrinsicID() == Intrinsic::dbg_addr;
163 static bool classof(const Value *V) {
164 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
168 /// This represents the llvm.dbg.value instruction.
169 class DbgValueInst : public DbgVariableIntrinsic {
170 public:
171 Value *getValue() const {
172 return getVariableLocation(/* AllowNullOp = */ false);
175 /// \name Casting methods
176 /// @{
177 static bool classof(const IntrinsicInst *I) {
178 return I->getIntrinsicID() == Intrinsic::dbg_value;
180 static bool classof(const Value *V) {
181 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
183 /// @}
186 /// This represents the llvm.dbg.label instruction.
187 class DbgLabelInst : public DbgInfoIntrinsic {
188 public:
189 DILabel *getLabel() const {
190 return cast<DILabel>(getRawLabel());
193 Metadata *getRawLabel() const {
194 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
197 /// Methods for support type inquiry through isa, cast, and dyn_cast:
198 /// @{
199 static bool classof(const IntrinsicInst *I) {
200 return I->getIntrinsicID() == Intrinsic::dbg_label;
202 static bool classof(const Value *V) {
203 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
205 /// @}
208 /// This is the common base class for constrained floating point intrinsics.
209 class ConstrainedFPIntrinsic : public IntrinsicInst {
210 public:
211 enum RoundingMode {
212 rmInvalid,
213 rmDynamic,
214 rmToNearest,
215 rmDownward,
216 rmUpward,
217 rmTowardZero
220 enum ExceptionBehavior {
221 ebInvalid,
222 ebIgnore,
223 ebMayTrap,
224 ebStrict
227 bool isUnaryOp() const;
228 bool isTernaryOp() const;
229 RoundingMode getRoundingMode() const;
230 ExceptionBehavior getExceptionBehavior() const;
232 // Methods for support type inquiry through isa, cast, and dyn_cast:
233 static bool classof(const IntrinsicInst *I) {
234 switch (I->getIntrinsicID()) {
235 case Intrinsic::experimental_constrained_fadd:
236 case Intrinsic::experimental_constrained_fsub:
237 case Intrinsic::experimental_constrained_fmul:
238 case Intrinsic::experimental_constrained_fdiv:
239 case Intrinsic::experimental_constrained_frem:
240 case Intrinsic::experimental_constrained_fma:
241 case Intrinsic::experimental_constrained_sqrt:
242 case Intrinsic::experimental_constrained_pow:
243 case Intrinsic::experimental_constrained_powi:
244 case Intrinsic::experimental_constrained_sin:
245 case Intrinsic::experimental_constrained_cos:
246 case Intrinsic::experimental_constrained_exp:
247 case Intrinsic::experimental_constrained_exp2:
248 case Intrinsic::experimental_constrained_log:
249 case Intrinsic::experimental_constrained_log10:
250 case Intrinsic::experimental_constrained_log2:
251 case Intrinsic::experimental_constrained_rint:
252 case Intrinsic::experimental_constrained_nearbyint:
253 case Intrinsic::experimental_constrained_maxnum:
254 case Intrinsic::experimental_constrained_minnum:
255 case Intrinsic::experimental_constrained_ceil:
256 case Intrinsic::experimental_constrained_floor:
257 case Intrinsic::experimental_constrained_round:
258 case Intrinsic::experimental_constrained_trunc:
259 return true;
260 default: return false;
263 static bool classof(const Value *V) {
264 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
268 /// Common base class for all memory intrinsics. Simply provides
269 /// common methods.
270 /// Written as CRTP to avoid a common base class amongst the
271 /// three atomicity hierarchies.
272 template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
273 private:
274 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
276 public:
277 Value *getRawDest() const {
278 return const_cast<Value *>(getArgOperand(ARG_DEST));
280 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
281 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
283 Value *getLength() const {
284 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
286 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
287 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
289 /// This is just like getRawDest, but it strips off any cast
290 /// instructions (including addrspacecast) that feed it, giving the
291 /// original input. The returned value is guaranteed to be a pointer.
292 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
294 unsigned getDestAddressSpace() const {
295 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
298 unsigned getDestAlignment() const { return getParamAlignment(ARG_DEST); }
300 /// Set the specified arguments of the instruction.
301 void setDest(Value *Ptr) {
302 assert(getRawDest()->getType() == Ptr->getType() &&
303 "setDest called with pointer of wrong type!");
304 setArgOperand(ARG_DEST, Ptr);
307 void setDestAlignment(unsigned Align) {
308 removeParamAttr(ARG_DEST, Attribute::Alignment);
309 if (Align > 0)
310 addParamAttr(ARG_DEST,
311 Attribute::getWithAlignment(getContext(), Align));
314 void setLength(Value *L) {
315 assert(getLength()->getType() == L->getType() &&
316 "setLength called with value of wrong type!");
317 setArgOperand(ARG_LENGTH, L);
321 /// Common base class for all memory transfer intrinsics. Simply provides
322 /// common methods.
323 template <class BaseCL> class MemTransferBase : public BaseCL {
324 private:
325 enum { ARG_SOURCE = 1 };
327 public:
328 /// Return the arguments to the instruction.
329 Value *getRawSource() const {
330 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
332 const Use &getRawSourceUse() const {
333 return BaseCL::getArgOperandUse(ARG_SOURCE);
335 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
337 /// This is just like getRawSource, but it strips off any cast
338 /// instructions that feed it, giving the original input. The returned
339 /// value is guaranteed to be a pointer.
340 Value *getSource() const { return getRawSource()->stripPointerCasts(); }
342 unsigned getSourceAddressSpace() const {
343 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
346 unsigned getSourceAlignment() const {
347 return BaseCL::getParamAlignment(ARG_SOURCE);
350 void setSource(Value *Ptr) {
351 assert(getRawSource()->getType() == Ptr->getType() &&
352 "setSource called with pointer of wrong type!");
353 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
356 void setSourceAlignment(unsigned Align) {
357 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
358 if (Align > 0)
359 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
360 BaseCL::getContext(), Align));
364 /// Common base class for all memset intrinsics. Simply provides
365 /// common methods.
366 template <class BaseCL> class MemSetBase : public BaseCL {
367 private:
368 enum { ARG_VALUE = 1 };
370 public:
371 Value *getValue() const {
372 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
374 const Use &getValueUse() const {
375 return BaseCL::getArgOperandUse(ARG_VALUE);
377 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
379 void setValue(Value *Val) {
380 assert(getValue()->getType() == Val->getType() &&
381 "setValue called with value of wrong type!");
382 BaseCL::setArgOperand(ARG_VALUE, Val);
386 // The common base class for the atomic memset/memmove/memcpy intrinsics
387 // i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
388 class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
389 private:
390 enum { ARG_ELEMENTSIZE = 3 };
392 public:
393 Value *getRawElementSizeInBytes() const {
394 return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
397 ConstantInt *getElementSizeInBytesCst() const {
398 return cast<ConstantInt>(getRawElementSizeInBytes());
401 uint32_t getElementSizeInBytes() const {
402 return getElementSizeInBytesCst()->getZExtValue();
405 void setElementSizeInBytes(Constant *V) {
406 assert(V->getType() == Type::getInt8Ty(getContext()) &&
407 "setElementSizeInBytes called with value of wrong type!");
408 setArgOperand(ARG_ELEMENTSIZE, V);
411 static bool classof(const IntrinsicInst *I) {
412 switch (I->getIntrinsicID()) {
413 case Intrinsic::memcpy_element_unordered_atomic:
414 case Intrinsic::memmove_element_unordered_atomic:
415 case Intrinsic::memset_element_unordered_atomic:
416 return true;
417 default:
418 return false;
421 static bool classof(const Value *V) {
422 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
426 /// This class represents atomic memset intrinsic
427 // i.e. llvm.element.unordered.atomic.memset
428 class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
429 public:
430 static bool classof(const IntrinsicInst *I) {
431 return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
433 static bool classof(const Value *V) {
434 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
438 // This class wraps the atomic memcpy/memmove intrinsics
439 // i.e. llvm.element.unordered.atomic.memcpy/memmove
440 class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
441 public:
442 static bool classof(const IntrinsicInst *I) {
443 switch (I->getIntrinsicID()) {
444 case Intrinsic::memcpy_element_unordered_atomic:
445 case Intrinsic::memmove_element_unordered_atomic:
446 return true;
447 default:
448 return false;
451 static bool classof(const Value *V) {
452 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
456 /// This class represents the atomic memcpy intrinsic
457 /// i.e. llvm.element.unordered.atomic.memcpy
458 class AtomicMemCpyInst : public AtomicMemTransferInst {
459 public:
460 static bool classof(const IntrinsicInst *I) {
461 return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
463 static bool classof(const Value *V) {
464 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
468 /// This class represents the atomic memmove intrinsic
469 /// i.e. llvm.element.unordered.atomic.memmove
470 class AtomicMemMoveInst : public AtomicMemTransferInst {
471 public:
472 static bool classof(const IntrinsicInst *I) {
473 return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
475 static bool classof(const Value *V) {
476 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
480 /// This is the common base class for memset/memcpy/memmove.
481 class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
482 private:
483 enum { ARG_VOLATILE = 3 };
485 public:
486 ConstantInt *getVolatileCst() const {
487 return cast<ConstantInt>(
488 const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
491 bool isVolatile() const {
492 return !getVolatileCst()->isZero();
495 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
497 // Methods for support type inquiry through isa, cast, and dyn_cast:
498 static bool classof(const IntrinsicInst *I) {
499 switch (I->getIntrinsicID()) {
500 case Intrinsic::memcpy:
501 case Intrinsic::memmove:
502 case Intrinsic::memset:
503 return true;
504 default: return false;
507 static bool classof(const Value *V) {
508 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
512 /// This class wraps the llvm.memset intrinsic.
513 class MemSetInst : public MemSetBase<MemIntrinsic> {
514 public:
515 // Methods for support type inquiry through isa, cast, and dyn_cast:
516 static bool classof(const IntrinsicInst *I) {
517 return I->getIntrinsicID() == Intrinsic::memset;
519 static bool classof(const Value *V) {
520 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
524 /// This class wraps the llvm.memcpy/memmove intrinsics.
525 class MemTransferInst : public MemTransferBase<MemIntrinsic> {
526 public:
527 // Methods for support type inquiry through isa, cast, and dyn_cast:
528 static bool classof(const IntrinsicInst *I) {
529 return I->getIntrinsicID() == Intrinsic::memcpy ||
530 I->getIntrinsicID() == Intrinsic::memmove;
532 static bool classof(const Value *V) {
533 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
537 /// This class wraps the llvm.memcpy intrinsic.
538 class MemCpyInst : public MemTransferInst {
539 public:
540 // Methods for support type inquiry through isa, cast, and dyn_cast:
541 static bool classof(const IntrinsicInst *I) {
542 return I->getIntrinsicID() == Intrinsic::memcpy;
544 static bool classof(const Value *V) {
545 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
549 /// This class wraps the llvm.memmove intrinsic.
550 class MemMoveInst : public MemTransferInst {
551 public:
552 // Methods for support type inquiry through isa, cast, and dyn_cast:
553 static bool classof(const IntrinsicInst *I) {
554 return I->getIntrinsicID() == Intrinsic::memmove;
556 static bool classof(const Value *V) {
557 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
561 // The common base class for any memset/memmove/memcpy intrinsics;
562 // whether they be atomic or non-atomic.
563 // i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
564 // and llvm.memset/memcpy/memmove
565 class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
566 public:
567 bool isVolatile() const {
568 // Only the non-atomic intrinsics can be volatile
569 if (auto *MI = dyn_cast<MemIntrinsic>(this))
570 return MI->isVolatile();
571 return false;
574 static bool classof(const IntrinsicInst *I) {
575 switch (I->getIntrinsicID()) {
576 case Intrinsic::memcpy:
577 case Intrinsic::memmove:
578 case Intrinsic::memset:
579 case Intrinsic::memcpy_element_unordered_atomic:
580 case Intrinsic::memmove_element_unordered_atomic:
581 case Intrinsic::memset_element_unordered_atomic:
582 return true;
583 default:
584 return false;
587 static bool classof(const Value *V) {
588 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
592 /// This class represents any memset intrinsic
593 // i.e. llvm.element.unordered.atomic.memset
594 // and llvm.memset
595 class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
596 public:
597 static bool classof(const IntrinsicInst *I) {
598 switch (I->getIntrinsicID()) {
599 case Intrinsic::memset:
600 case Intrinsic::memset_element_unordered_atomic:
601 return true;
602 default:
603 return false;
606 static bool classof(const Value *V) {
607 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
611 // This class wraps any memcpy/memmove intrinsics
612 // i.e. llvm.element.unordered.atomic.memcpy/memmove
613 // and llvm.memcpy/memmove
614 class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
615 public:
616 static bool classof(const IntrinsicInst *I) {
617 switch (I->getIntrinsicID()) {
618 case Intrinsic::memcpy:
619 case Intrinsic::memmove:
620 case Intrinsic::memcpy_element_unordered_atomic:
621 case Intrinsic::memmove_element_unordered_atomic:
622 return true;
623 default:
624 return false;
627 static bool classof(const Value *V) {
628 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
632 /// This class represents any memcpy intrinsic
633 /// i.e. llvm.element.unordered.atomic.memcpy
634 /// and llvm.memcpy
635 class AnyMemCpyInst : public AnyMemTransferInst {
636 public:
637 static bool classof(const IntrinsicInst *I) {
638 switch (I->getIntrinsicID()) {
639 case Intrinsic::memcpy:
640 case Intrinsic::memcpy_element_unordered_atomic:
641 return true;
642 default:
643 return false;
646 static bool classof(const Value *V) {
647 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
651 /// This class represents any memmove intrinsic
652 /// i.e. llvm.element.unordered.atomic.memmove
653 /// and llvm.memmove
654 class AnyMemMoveInst : public AnyMemTransferInst {
655 public:
656 static bool classof(const IntrinsicInst *I) {
657 switch (I->getIntrinsicID()) {
658 case Intrinsic::memmove:
659 case Intrinsic::memmove_element_unordered_atomic:
660 return true;
661 default:
662 return false;
665 static bool classof(const Value *V) {
666 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
670 /// This represents the llvm.va_start intrinsic.
671 class VAStartInst : public IntrinsicInst {
672 public:
673 static bool classof(const IntrinsicInst *I) {
674 return I->getIntrinsicID() == Intrinsic::vastart;
676 static bool classof(const Value *V) {
677 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
680 Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
683 /// This represents the llvm.va_end intrinsic.
684 class VAEndInst : public IntrinsicInst {
685 public:
686 static bool classof(const IntrinsicInst *I) {
687 return I->getIntrinsicID() == Intrinsic::vaend;
689 static bool classof(const Value *V) {
690 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
693 Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
696 /// This represents the llvm.va_copy intrinsic.
697 class VACopyInst : public IntrinsicInst {
698 public:
699 static bool classof(const IntrinsicInst *I) {
700 return I->getIntrinsicID() == Intrinsic::vacopy;
702 static bool classof(const Value *V) {
703 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
706 Value *getDest() const { return const_cast<Value*>(getArgOperand(0)); }
707 Value *getSrc() const { return const_cast<Value*>(getArgOperand(1)); }
710 /// This represents the llvm.instrprof_increment intrinsic.
711 class InstrProfIncrementInst : public IntrinsicInst {
712 public:
713 static bool classof(const IntrinsicInst *I) {
714 return I->getIntrinsicID() == Intrinsic::instrprof_increment;
716 static bool classof(const Value *V) {
717 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
720 GlobalVariable *getName() const {
721 return cast<GlobalVariable>(
722 const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
725 ConstantInt *getHash() const {
726 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
729 ConstantInt *getNumCounters() const {
730 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
733 ConstantInt *getIndex() const {
734 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
737 Value *getStep() const;
740 class InstrProfIncrementInstStep : public InstrProfIncrementInst {
741 public:
742 static bool classof(const IntrinsicInst *I) {
743 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
745 static bool classof(const Value *V) {
746 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
750 /// This represents the llvm.instrprof_value_profile intrinsic.
751 class InstrProfValueProfileInst : public IntrinsicInst {
752 public:
753 static bool classof(const IntrinsicInst *I) {
754 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
756 static bool classof(const Value *V) {
757 return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
760 GlobalVariable *getName() const {
761 return cast<GlobalVariable>(
762 const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
765 ConstantInt *getHash() const {
766 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
769 Value *getTargetValue() const {
770 return cast<Value>(const_cast<Value *>(getArgOperand(2)));
773 ConstantInt *getValueKind() const {
774 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
777 // Returns the value site index.
778 ConstantInt *getIndex() const {
779 return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
783 } // end namespace llvm
785 #endif // LLVM_IR_INTRINSICINST_H