LLVM  7.0.0svn
IntrinsicInst.h
Go to the documentation of this file.
1 //===-- llvm/IntrinsicInst.h - Intrinsic Instruction Wrappers ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines classes that make it really easy to deal with intrinsic
11 // functions with the isa/dyncast family of functions. In particular, this
12 // allows you to do things like:
13 //
14 // if (MemCpyInst *MCI = dyn_cast<MemCpyInst>(Inst))
15 // ... MCI->getDest() ... MCI->getSource() ...
16 //
17 // All intrinsic function calls are instances of the call instruction, so these
18 // are all subclasses of the CallInst class. Note that none of these classes
19 // has state or virtual methods, which is an important part of this gross/neat
20 // hack working.
21 //
22 //===----------------------------------------------------------------------===//
23 
24 #ifndef LLVM_IR_INTRINSICINST_H
25 #define LLVM_IR_INTRINSICINST_H
26 
27 #include "llvm/IR/Constants.h"
28 #include "llvm/IR/DerivedTypes.h"
29 #include "llvm/IR/Function.h"
30 #include "llvm/IR/GlobalVariable.h"
31 #include "llvm/IR/Instructions.h"
32 #include "llvm/IR/Intrinsics.h"
33 #include "llvm/IR/Metadata.h"
34 #include "llvm/IR/Value.h"
35 #include "llvm/Support/Casting.h"
36 #include <cassert>
37 #include <cstdint>
38 
39 namespace llvm {
40 
41  /// A wrapper class for inspecting calls to intrinsic functions.
42  /// This allows the standard isa/dyncast/cast functionality to work with calls
43  /// to intrinsic functions.
44  class IntrinsicInst : public CallInst {
45  public:
46  IntrinsicInst() = delete;
47  IntrinsicInst(const IntrinsicInst &) = delete;
48  IntrinsicInst &operator=(const IntrinsicInst &) = delete;
49 
50  /// Return the intrinsic ID of this intrinsic.
53  }
54 
55  // Methods for support type inquiry through isa, cast, and dyn_cast:
56  static bool classof(const CallInst *I) {
57  if (const Function *CF = I->getCalledFunction())
58  return CF->isIntrinsic();
59  return false;
60  }
61  static bool classof(const Value *V) {
62  return isa<CallInst>(V) && classof(cast<CallInst>(V));
63  }
64  };
65 
66  /// This is the common base class for debug info intrinsics.
68  public:
69  /// Get the location corresponding to the variable referenced by the debug
70  /// info intrinsic. Depending on the intrinsic, this could be the
71  /// variable's value or its address.
72  Value *getVariableLocation(bool AllowNullOp = true) const;
73 
74  /// Does this describe the address of a local variable. True for dbg.addr
75  /// and dbg.declare, but not dbg.value, which describes its value.
76  bool isAddressOfVariable() const {
77  return getIntrinsicID() != Intrinsic::dbg_value;
78  }
79 
81  return cast<DILocalVariable>(getRawVariable());
82  }
83 
85  return cast<DIExpression>(getRawExpression());
86  }
87 
89  return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
90  }
91 
93  return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
94  }
95 
96  /// \name Casting methods
97  /// @{
98  static bool classof(const IntrinsicInst *I) {
99  switch (I->getIntrinsicID()) {
100  case Intrinsic::dbg_declare:
101  case Intrinsic::dbg_value:
102  case Intrinsic::dbg_addr:
103  return true;
104  default: return false;
105  }
106  }
107  static bool classof(const Value *V) {
108  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
109  }
110  /// @}
111  };
112 
113  /// This represents the llvm.dbg.declare instruction.
115  public:
116  Value *getAddress() const { return getVariableLocation(); }
117 
118  /// \name Casting methods
119  /// @{
120  static bool classof(const IntrinsicInst *I) {
121  return I->getIntrinsicID() == Intrinsic::dbg_declare;
122  }
123  static bool classof(const Value *V) {
124  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
125  }
126  /// @}
127  };
128 
129  /// This represents the llvm.dbg.addr instruction.
131  public:
132  Value *getAddress() const { return getVariableLocation(); }
133 
134  /// \name Casting methods
135  /// @{
136  static bool classof(const IntrinsicInst *I) {
137  return I->getIntrinsicID() == Intrinsic::dbg_addr;
138  }
139  static bool classof(const Value *V) {
140  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
141  }
142  };
143 
144  /// This represents the llvm.dbg.value instruction.
146  public:
147  Value *getValue() const {
148  return getVariableLocation(/* AllowNullOp = */ false);
149  }
150 
151  /// \name Casting methods
152  /// @{
153  static bool classof(const IntrinsicInst *I) {
154  return I->getIntrinsicID() == Intrinsic::dbg_value;
155  }
156  static bool classof(const Value *V) {
157  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
158  }
159  /// @}
160  };
161 
162  /// This is the common base class for constrained floating point intrinsics.
164  public:
171  rmTowardZero
172  };
173 
178  ebStrict
179  };
180 
181  bool isUnaryOp() const;
182  bool isTernaryOp() const;
183  RoundingMode getRoundingMode() const;
184  ExceptionBehavior getExceptionBehavior() const;
185 
186  // Methods for support type inquiry through isa, cast, and dyn_cast:
187  static bool classof(const IntrinsicInst *I) {
188  switch (I->getIntrinsicID()) {
189  case Intrinsic::experimental_constrained_fadd:
190  case Intrinsic::experimental_constrained_fsub:
191  case Intrinsic::experimental_constrained_fmul:
192  case Intrinsic::experimental_constrained_fdiv:
193  case Intrinsic::experimental_constrained_frem:
194  case Intrinsic::experimental_constrained_fma:
195  case Intrinsic::experimental_constrained_sqrt:
196  case Intrinsic::experimental_constrained_pow:
197  case Intrinsic::experimental_constrained_powi:
198  case Intrinsic::experimental_constrained_sin:
199  case Intrinsic::experimental_constrained_cos:
200  case Intrinsic::experimental_constrained_exp:
201  case Intrinsic::experimental_constrained_exp2:
202  case Intrinsic::experimental_constrained_log:
203  case Intrinsic::experimental_constrained_log10:
204  case Intrinsic::experimental_constrained_log2:
205  case Intrinsic::experimental_constrained_rint:
206  case Intrinsic::experimental_constrained_nearbyint:
207  return true;
208  default: return false;
209  }
210  }
211  static bool classof(const Value *V) {
212  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
213  }
214  };
215 
216  /// Common base class for all memory intrinsics. Simply provides
217  /// common methods.
218  /// Written as CRTP to avoid a common base class amongst the
219  /// three atomicity hierarchies.
220  template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
221  private:
222  enum { ARG_DEST = 0, ARG_LENGTH = 2 };
223 
224  public:
225  Value *getRawDest() const {
226  return const_cast<Value *>(getArgOperand(ARG_DEST));
227  }
228  const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
229  Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
230 
231  Value *getLength() const {
232  return const_cast<Value *>(getArgOperand(ARG_LENGTH));
233  }
234  const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
235  Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
236 
237  /// This is just like getRawDest, but it strips off any cast
238  /// instructions (including addrspacecast) that feed it, giving the
239  /// original input. The returned value is guaranteed to be a pointer.
240  Value *getDest() const { return getRawDest()->stripPointerCasts(); }
241 
242  unsigned getDestAddressSpace() const {
243  return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
244  }
245 
246  unsigned getDestAlignment() const { return getParamAlignment(ARG_DEST); }
247 
248  /// Set the specified arguments of the instruction.
249  void setDest(Value *Ptr) {
250  assert(getRawDest()->getType() == Ptr->getType() &&
251  "setDest called with pointer of wrong type!");
252  setArgOperand(ARG_DEST, Ptr);
253  }
254 
255  void setDestAlignment(unsigned Align) {
256  removeParamAttr(ARG_DEST, Attribute::Alignment);
257  if (Align > 0)
258  addParamAttr(ARG_DEST,
260  }
261 
262  void setLength(Value *L) {
263  assert(getLength()->getType() == L->getType() &&
264  "setLength called with value of wrong type!");
265  setArgOperand(ARG_LENGTH, L);
266  }
267  };
268 
269  /// Common base class for all memory transfer intrinsics. Simply provides
270  /// common methods.
271  template <class BaseCL> class MemTransferBase : public BaseCL {
272  private:
273  enum { ARG_SOURCE = 1 };
274 
275  public:
276  /// Return the arguments to the instruction.
277  Value *getRawSource() const {
278  return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
279  }
280  const Use &getRawSourceUse() const {
281  return BaseCL::getArgOperandUse(ARG_SOURCE);
282  }
283  Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
284 
285  /// This is just like getRawSource, but it strips off any cast
286  /// instructions that feed it, giving the original input. The returned
287  /// value is guaranteed to be a pointer.
288  Value *getSource() const { return getRawSource()->stripPointerCasts(); }
289 
290  unsigned getSourceAddressSpace() const {
291  return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
292  }
293 
294  unsigned getSourceAlignment() const {
295  return BaseCL::getParamAlignment(ARG_SOURCE);
296  }
297 
298  void setSource(Value *Ptr) {
299  assert(getRawSource()->getType() == Ptr->getType() &&
300  "setSource called with pointer of wrong type!");
301  BaseCL::setArgOperand(ARG_SOURCE, Ptr);
302  }
303 
304  void setSourceAlignment(unsigned Align) {
305  BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
306  if (Align > 0)
307  BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
308  BaseCL::getContext(), Align));
309  }
310  };
311 
312  /// Common base class for all memset intrinsics. Simply provides
313  /// common methods.
314  template <class BaseCL> class MemSetBase : public BaseCL {
315  private:
316  enum { ARG_VALUE = 1 };
317 
318  public:
319  Value *getValue() const {
320  return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
321  }
322  const Use &getValueUse() const {
323  return BaseCL::getArgOperandUse(ARG_VALUE);
324  }
325  Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
326 
327  void setValue(Value *Val) {
328  assert(getValue()->getType() == Val->getType() &&
329  "setValue called with value of wrong type!");
330  BaseCL::setArgOperand(ARG_VALUE, Val);
331  }
332  };
333 
334  // The common base class for the atomic memset/memmove/memcpy intrinsics
335  // i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
336  class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
337  private:
338  enum { ARG_ELEMENTSIZE = 3 };
339 
340  public:
342  return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
343  }
344 
346  return cast<ConstantInt>(getRawElementSizeInBytes());
347  }
348 
350  return getElementSizeInBytesCst()->getZExtValue();
351  }
352 
355  "setElementSizeInBytes called with value of wrong type!");
356  setArgOperand(ARG_ELEMENTSIZE, V);
357  }
358 
359  static bool classof(const IntrinsicInst *I) {
360  switch (I->getIntrinsicID()) {
361  case Intrinsic::memcpy_element_unordered_atomic:
362  case Intrinsic::memmove_element_unordered_atomic:
363  case Intrinsic::memset_element_unordered_atomic:
364  return true;
365  default:
366  return false;
367  }
368  }
369  static bool classof(const Value *V) {
370  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
371  }
372  };
373 
374  /// This class represents atomic memset intrinsic
375  // i.e. llvm.element.unordered.atomic.memset
376  class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
377  public:
378  static bool classof(const IntrinsicInst *I) {
379  return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
380  }
381  static bool classof(const Value *V) {
382  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
383  }
384  };
385 
386  // This class wraps the atomic memcpy/memmove intrinsics
387  // i.e. llvm.element.unordered.atomic.memcpy/memmove
388  class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
389  public:
390  static bool classof(const IntrinsicInst *I) {
391  switch (I->getIntrinsicID()) {
392  case Intrinsic::memcpy_element_unordered_atomic:
393  case Intrinsic::memmove_element_unordered_atomic:
394  return true;
395  default:
396  return false;
397  }
398  }
399  static bool classof(const Value *V) {
400  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
401  }
402  };
403 
404  /// This class represents the atomic memcpy intrinsic
405  /// i.e. llvm.element.unordered.atomic.memcpy
407  public:
408  static bool classof(const IntrinsicInst *I) {
409  return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
410  }
411  static bool classof(const Value *V) {
412  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
413  }
414  };
415 
416  /// This class represents the atomic memmove intrinsic
417  /// i.e. llvm.element.unordered.atomic.memmove
419  public:
420  static bool classof(const IntrinsicInst *I) {
421  return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
422  }
423  static bool classof(const Value *V) {
424  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
425  }
426  };
427 
428  /// This is the common base class for memset/memcpy/memmove.
429  class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
430  private:
431  enum { ARG_VOLATILE = 3 };
432 
433  public:
435  return cast<ConstantInt>(
436  const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
437  }
438 
439  bool isVolatile() const {
440  return !getVolatileCst()->isZero();
441  }
442 
443  void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
444 
445  // Methods for support type inquiry through isa, cast, and dyn_cast:
446  static bool classof(const IntrinsicInst *I) {
447  switch (I->getIntrinsicID()) {
448  case Intrinsic::memcpy:
449  case Intrinsic::memmove:
450  case Intrinsic::memset:
451  return true;
452  default: return false;
453  }
454  }
455  static bool classof(const Value *V) {
456  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
457  }
458  };
459 
460  /// This class wraps the llvm.memset intrinsic.
461  class MemSetInst : public MemSetBase<MemIntrinsic> {
462  public:
463  // Methods for support type inquiry through isa, cast, and dyn_cast:
464  static bool classof(const IntrinsicInst *I) {
465  return I->getIntrinsicID() == Intrinsic::memset;
466  }
467  static bool classof(const Value *V) {
468  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
469  }
470  };
471 
472  /// This class wraps the llvm.memcpy/memmove intrinsics.
473  class MemTransferInst : public MemTransferBase<MemIntrinsic> {
474  public:
475  // Methods for support type inquiry through isa, cast, and dyn_cast:
476  static bool classof(const IntrinsicInst *I) {
477  return I->getIntrinsicID() == Intrinsic::memcpy ||
478  I->getIntrinsicID() == Intrinsic::memmove;
479  }
480  static bool classof(const Value *V) {
481  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
482  }
483  };
484 
485  /// This class wraps the llvm.memcpy intrinsic.
486  class MemCpyInst : public MemTransferInst {
487  public:
488  // Methods for support type inquiry through isa, cast, and dyn_cast:
489  static bool classof(const IntrinsicInst *I) {
490  return I->getIntrinsicID() == Intrinsic::memcpy;
491  }
492  static bool classof(const Value *V) {
493  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
494  }
495  };
496 
497  /// This class wraps the llvm.memmove intrinsic.
498  class MemMoveInst : public MemTransferInst {
499  public:
500  // Methods for support type inquiry through isa, cast, and dyn_cast:
501  static bool classof(const IntrinsicInst *I) {
502  return I->getIntrinsicID() == Intrinsic::memmove;
503  }
504  static bool classof(const Value *V) {
505  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
506  }
507  };
508 
509  // The common base class for any memset/memmove/memcpy intrinsics;
510  // whether they be atomic or non-atomic.
511  // i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
512  // and llvm.memset/memcpy/memmove
513  class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
514  public:
515  bool isVolatile() const {
516  // Only the non-atomic intrinsics can be volatile
517  if (auto *MI = dyn_cast<MemIntrinsic>(this))
518  return MI->isVolatile();
519  return false;
520  }
521 
522  static bool classof(const IntrinsicInst *I) {
523  switch (I->getIntrinsicID()) {
524  case Intrinsic::memcpy:
525  case Intrinsic::memmove:
526  case Intrinsic::memset:
527  case Intrinsic::memcpy_element_unordered_atomic:
528  case Intrinsic::memmove_element_unordered_atomic:
529  case Intrinsic::memset_element_unordered_atomic:
530  return true;
531  default:
532  return false;
533  }
534  }
535  static bool classof(const Value *V) {
536  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
537  }
538  };
539 
540  /// This class represents any memset intrinsic
541  // i.e. llvm.element.unordered.atomic.memset
542  // and llvm.memset
543  class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
544  public:
545  static bool classof(const IntrinsicInst *I) {
546  switch (I->getIntrinsicID()) {
547  case Intrinsic::memset:
548  case Intrinsic::memset_element_unordered_atomic:
549  return true;
550  default:
551  return false;
552  }
553  }
554  static bool classof(const Value *V) {
555  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
556  }
557  };
558 
559  // This class wraps any memcpy/memmove intrinsics
560  // i.e. llvm.element.unordered.atomic.memcpy/memmove
561  // and llvm.memcpy/memmove
562  class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
563  public:
564  static bool classof(const IntrinsicInst *I) {
565  switch (I->getIntrinsicID()) {
566  case Intrinsic::memcpy:
567  case Intrinsic::memmove:
568  case Intrinsic::memcpy_element_unordered_atomic:
569  case Intrinsic::memmove_element_unordered_atomic:
570  return true;
571  default:
572  return false;
573  }
574  }
575  static bool classof(const Value *V) {
576  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
577  }
578  };
579 
580  /// This class represents any memcpy intrinsic
581  /// i.e. llvm.element.unordered.atomic.memcpy
582  /// and llvm.memcpy
584  public:
585  static bool classof(const IntrinsicInst *I) {
586  switch (I->getIntrinsicID()) {
587  case Intrinsic::memcpy:
588  case Intrinsic::memcpy_element_unordered_atomic:
589  return true;
590  default:
591  return false;
592  }
593  }
594  static bool classof(const Value *V) {
595  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
596  }
597  };
598 
599  /// This class represents any memmove intrinsic
600  /// i.e. llvm.element.unordered.atomic.memmove
601  /// and llvm.memmove
603  public:
604  static bool classof(const IntrinsicInst *I) {
605  switch (I->getIntrinsicID()) {
606  case Intrinsic::memmove:
607  case Intrinsic::memmove_element_unordered_atomic:
608  return true;
609  default:
610  return false;
611  }
612  }
613  static bool classof(const Value *V) {
614  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
615  }
616  };
617 
618  /// This represents the llvm.va_start intrinsic.
619  class VAStartInst : public IntrinsicInst {
620  public:
621  static bool classof(const IntrinsicInst *I) {
622  return I->getIntrinsicID() == Intrinsic::vastart;
623  }
624  static bool classof(const Value *V) {
625  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
626  }
627 
628  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
629  };
630 
631  /// This represents the llvm.va_end intrinsic.
632  class VAEndInst : public IntrinsicInst {
633  public:
634  static bool classof(const IntrinsicInst *I) {
635  return I->getIntrinsicID() == Intrinsic::vaend;
636  }
637  static bool classof(const Value *V) {
638  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
639  }
640 
641  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
642  };
643 
644  /// This represents the llvm.va_copy intrinsic.
645  class VACopyInst : public IntrinsicInst {
646  public:
647  static bool classof(const IntrinsicInst *I) {
648  return I->getIntrinsicID() == Intrinsic::vacopy;
649  }
650  static bool classof(const Value *V) {
651  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
652  }
653 
654  Value *getDest() const { return const_cast<Value*>(getArgOperand(0)); }
655  Value *getSrc() const { return const_cast<Value*>(getArgOperand(1)); }
656  };
657 
658  /// This represents the llvm.instrprof_increment intrinsic.
660  public:
661  static bool classof(const IntrinsicInst *I) {
662  return I->getIntrinsicID() == Intrinsic::instrprof_increment;
663  }
664  static bool classof(const Value *V) {
665  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
666  }
667 
669  return cast<GlobalVariable>(
670  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
671  }
672 
673  ConstantInt *getHash() const {
674  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
675  }
676 
678  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
679  }
680 
682  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
683  }
684 
685  Value *getStep() const;
686  };
687 
689  public:
690  static bool classof(const IntrinsicInst *I) {
691  return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
692  }
693  static bool classof(const Value *V) {
694  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
695  }
696  };
697 
698  /// This represents the llvm.instrprof_value_profile intrinsic.
700  public:
701  static bool classof(const IntrinsicInst *I) {
702  return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
703  }
704  static bool classof(const Value *V) {
705  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
706  }
707 
709  return cast<GlobalVariable>(
710  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
711  }
712 
713  ConstantInt *getHash() const {
714  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
715  }
716 
718  return cast<Value>(const_cast<Value *>(getArgOperand(2)));
719  }
720 
722  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
723  }
724 
725  // Returns the value site index.
727  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
728  }
729  };
730 
731 } // end namespace llvm
732 
733 #endif // LLVM_IR_INTRINSICINST_H
static bool classof(const Value *V)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
IntrinsicInst & operator=(const IntrinsicInst &)=delete
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
Value * getSrc() const
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This represents the llvm.va_end intrinsic.
static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:124
Value * getRawElementSizeInBytes() const
Metadata * getRawVariable() const
Definition: IntrinsicInst.h:88
This class represents a function call, abstracting a target machine&#39;s calling convention.
This file contains the declarations for metadata subclasses.
static bool classof(const CallInst *I)
Definition: IntrinsicInst.h:56
unsigned getSourceAlignment() const
static bool classof(const IntrinsicInst *I)
Value * getValue() const
This class represents the atomic memcpy intrinsic i.e.
unsigned getSourceAddressSpace() const
static bool classof(const Value *V)
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:738
void setSource(Value *Ptr)
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
This class wraps the llvm.memset intrinsic.
void setVolatile(Constant *V)
static bool classof(const Value *V)
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
This is the common base class for constrained floating point intrinsics.
Value * getLength() const
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Value * getArgList() const
static bool classof(const IntrinsicInst *I)
Definition: IntrinsicInst.h:98
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions (including addrspacecast) that ...
static bool classof(const Value *V)
This class wraps the llvm.memmove intrinsic.
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
unsigned getDestAlignment() const
This class represents atomic memset intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
This represents the llvm.va_start intrinsic.
const Use & getRawSourceUse() const
void setLength(Value *L)
static bool classof(const Value *V)
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:195
static bool classof(const Value *V)
GlobalVariable * getName() const
ConstantInt * getNumCounters() const
static bool classof(const Value *V)
static bool classof(const Value *V)
Metadata * getRawExpression() const
Definition: IntrinsicInst.h:92
static bool classof(const Value *V)
const Use & getValueUse() const
ConstantInt * getHash() const
This class represents the atomic memmove intrinsic i.e.
static bool classof(const Value *V)
static bool classof(const Value *V)
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
bool isAddressOfVariable() const
Does this describe the address of a local variable.
Definition: IntrinsicInst.h:76
Value * getAddress() const
This is an important base class in LLVM.
Definition: Constant.h:42
Value * getValue() const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool classof(const Value *V)
DILocalVariable * getVariable() const
Definition: IntrinsicInst.h:80
static bool classof(const IntrinsicInst *I)
This class represents any memset intrinsic.
static bool classof(const Value *V)
DIExpression * getExpression() const
Definition: IntrinsicInst.h:84
void setArgOperand(unsigned i, Value *v)
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
bool isVolatile() const
static bool classof(const Value *V)
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
Definition: Value.cpp:567
This represents the llvm.dbg.addr instruction.
uint32_t getElementSizeInBytes() const
static bool classof(const IntrinsicInst *I)
Common base class for all memset intrinsics.
bool isVolatile() const
ConstantInt * getVolatileCst() const
ConstantInt * getElementSizeInBytesCst() const
static bool classof(const IntrinsicInst *I)
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Definition: IntrinsicInst.h:51
This is the common base class for memset/memcpy/memmove.
const Use & getLengthUse() const
This is the shared class of boolean and integer constants.
Definition: Constants.h:84
Value * getArgList() const
void setValue(Value *Val)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
This is the common base class for debug info intrinsics.
Definition: IntrinsicInst.h:67
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This class wraps the llvm.memcpy intrinsic.
Value * getRawSource() const
Return the arguments to the instruction.
static bool classof(const Value *V)
Common base class for all memory transfer intrinsics.
DWARF expression.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:175
static bool classof(const Value *V)
Value * getDest() const
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
This represents the llvm.instrprof_increment intrinsic.
void setElementSizeInBytes(Constant *V)
This class wraps the llvm.memcpy/memmove intrinsics.
unsigned getDestAddressSpace() const
static bool classof(const IntrinsicInst *I)
This represents the llvm.dbg.value instruction.
ConstantInt * getHash() const
#define I(x, y, z)
Definition: MD5.cpp:58
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
Common base class for all memory intrinsics.
static bool classof(const Value *V)
Definition: IntrinsicInst.h:61
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_copy intrinsic.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
static bool classof(const Value *V)
LLVM Value Representation.
Definition: Value.h:73
This class represents any memmove intrinsic i.e.
GlobalVariable * getName() const
ConstantInt * getValueKind() const
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
IRTranslator LLVM IR MI
void setSourceAlignment(unsigned Align)
This class represents any memcpy intrinsic i.e.
This represents the llvm.instrprof_value_profile intrinsic.
This represents the llvm.dbg.declare instruction.
static bool classof(const IntrinsicInst *I)
Root of the metadata hierarchy.
Definition: Metadata.h:58
static bool classof(const IntrinsicInst *I)
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:174
Value * getRawDest() const
static bool classof(const IntrinsicInst *I)
const Use & getRawDestUse() const
void setDestAlignment(unsigned Align)
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:44
Value * getAddress() const