LLVM  6.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  // Methods for support type inquiry through isa, cast, and dyn_cast:
75  static bool classof(const IntrinsicInst *I) {
76  switch (I->getIntrinsicID()) {
77  case Intrinsic::dbg_declare:
78  case Intrinsic::dbg_value:
79  return true;
80  default: return false;
81  }
82  }
83  static bool classof(const Value *V) {
84  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
85  }
86  };
87 
88  /// This represents the llvm.dbg.declare instruction.
90  public:
91  Value *getAddress() const { return getVariableLocation(); }
92 
94  return cast<DILocalVariable>(getRawVariable());
95  }
96 
98  return cast<DIExpression>(getRawExpression());
99  }
100 
102  return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
103  }
104 
106  return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
107  }
108 
109  // Methods for support type inquiry through isa, cast, and dyn_cast:
110  static bool classof(const IntrinsicInst *I) {
111  return I->getIntrinsicID() == Intrinsic::dbg_declare;
112  }
113  static bool classof(const Value *V) {
114  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
115  }
116  };
117 
118  /// This represents the llvm.dbg.value instruction.
120  public:
121  Value *getValue() const {
122  return getVariableLocation(/* AllowNullOp = */ false);
123  }
124 
125  uint64_t getOffset() const {
126  return cast<ConstantInt>(
127  const_cast<Value*>(getArgOperand(1)))->getZExtValue();
128  }
129 
131  return cast<DILocalVariable>(getRawVariable());
132  }
133 
135  return cast<DIExpression>(getRawExpression());
136  }
137 
139  return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
140  }
141 
143  return cast<MetadataAsValue>(getArgOperand(3))->getMetadata();
144  }
145 
146  // Methods for support type inquiry through isa, cast, and dyn_cast:
147  static bool classof(const IntrinsicInst *I) {
148  return I->getIntrinsicID() == Intrinsic::dbg_value;
149  }
150  static bool classof(const Value *V) {
151  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
152  }
153  };
154 
155  /// This is the common base class for constrained floating point intrinsics.
157  public:
164  rmTowardZero
165  };
166 
171  ebStrict
172  };
173 
174  bool isUnaryOp() const;
175  RoundingMode getRoundingMode() const;
176  ExceptionBehavior getExceptionBehavior() const;
177 
178  // Methods for support type inquiry through isa, cast, and dyn_cast:
179  static bool classof(const IntrinsicInst *I) {
180  switch (I->getIntrinsicID()) {
181  case Intrinsic::experimental_constrained_fadd:
182  case Intrinsic::experimental_constrained_fsub:
183  case Intrinsic::experimental_constrained_fmul:
184  case Intrinsic::experimental_constrained_fdiv:
185  case Intrinsic::experimental_constrained_frem:
186  case Intrinsic::experimental_constrained_sqrt:
187  case Intrinsic::experimental_constrained_pow:
188  case Intrinsic::experimental_constrained_powi:
189  case Intrinsic::experimental_constrained_sin:
190  case Intrinsic::experimental_constrained_cos:
191  case Intrinsic::experimental_constrained_exp:
192  case Intrinsic::experimental_constrained_exp2:
193  case Intrinsic::experimental_constrained_log:
194  case Intrinsic::experimental_constrained_log10:
195  case Intrinsic::experimental_constrained_log2:
196  case Intrinsic::experimental_constrained_rint:
197  case Intrinsic::experimental_constrained_nearbyint:
198  return true;
199  default: return false;
200  }
201  }
202  static bool classof(const Value *V) {
203  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
204  }
205  };
206 
207  /// This class represents atomic memcpy intrinsic
208  /// TODO: Integrate this class into MemIntrinsic hierarchy; for now this is
209  /// C&P of all methods from that hierarchy
211  private:
212  enum { ARG_DEST = 0, ARG_SOURCE = 1, ARG_LENGTH = 2, ARG_ELEMENTSIZE = 3 };
213 
214  public:
215  Value *getRawDest() const {
216  return const_cast<Value *>(getArgOperand(ARG_DEST));
217  }
218  const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
219  Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
220 
221  /// Return the arguments to the instruction.
222  Value *getRawSource() const {
223  return const_cast<Value *>(getArgOperand(ARG_SOURCE));
224  }
225  const Use &getRawSourceUse() const { return getArgOperandUse(ARG_SOURCE); }
226  Use &getRawSourceUse() { return getArgOperandUse(ARG_SOURCE); }
227 
228  Value *getLength() const {
229  return const_cast<Value *>(getArgOperand(ARG_LENGTH));
230  }
231  const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
232  Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
233 
234  bool isVolatile() const { return false; }
235 
237  return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
238  }
239 
241  return cast<ConstantInt>(getRawElementSizeInBytes());
242  }
243 
245  return getElementSizeInBytesCst()->getZExtValue();
246  }
247 
248  /// This is just like getRawDest, but it strips off any cast
249  /// instructions that feed it, giving the original input. The returned
250  /// value is guaranteed to be a pointer.
251  Value *getDest() const { return getRawDest()->stripPointerCasts(); }
252 
253  /// This is just like getRawSource, but it strips off any cast
254  /// instructions that feed it, giving the original input. The returned
255  /// value is guaranteed to be a pointer.
256  Value *getSource() const { return getRawSource()->stripPointerCasts(); }
257 
258  unsigned getDestAddressSpace() const {
259  return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
260  }
261 
262  unsigned getSourceAddressSpace() const {
263  return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
264  }
265 
266  /// Set the specified arguments of the instruction.
267  void setDest(Value *Ptr) {
268  assert(getRawDest()->getType() == Ptr->getType() &&
269  "setDest called with pointer of wrong type!");
270  setArgOperand(ARG_DEST, Ptr);
271  }
272 
273  void setSource(Value *Ptr) {
274  assert(getRawSource()->getType() == Ptr->getType() &&
275  "setSource called with pointer of wrong type!");
276  setArgOperand(ARG_SOURCE, Ptr);
277  }
278 
279  void setLength(Value *L) {
280  assert(getLength()->getType() == L->getType() &&
281  "setLength called with value of wrong type!");
282  setArgOperand(ARG_LENGTH, L);
283  }
284 
287  "setElementSizeInBytes called with value of wrong type!");
288  setArgOperand(ARG_ELEMENTSIZE, V);
289  }
290 
291  static bool classof(const IntrinsicInst *I) {
292  return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
293  }
294  static bool classof(const Value *V) {
295  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
296  }
297  };
298 
300  private:
301  enum { ARG_DEST = 0, ARG_SOURCE = 1, ARG_LENGTH = 2, ARG_ELEMENTSIZE = 3 };
302 
303  public:
304  Value *getRawDest() const {
305  return const_cast<Value *>(getArgOperand(ARG_DEST));
306  }
307  const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
308  Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
309 
310  /// Return the arguments to the instruction.
311  Value *getRawSource() const {
312  return const_cast<Value *>(getArgOperand(ARG_SOURCE));
313  }
314  const Use &getRawSourceUse() const { return getArgOperandUse(ARG_SOURCE); }
315  Use &getRawSourceUse() { return getArgOperandUse(ARG_SOURCE); }
316 
317  Value *getLength() const {
318  return const_cast<Value *>(getArgOperand(ARG_LENGTH));
319  }
320  const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
321  Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
322 
323  bool isVolatile() const { return false; }
324 
326  return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
327  }
328 
330  return cast<ConstantInt>(getRawElementSizeInBytes());
331  }
332 
334  return getElementSizeInBytesCst()->getZExtValue();
335  }
336 
337  /// This is just like getRawDest, 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 *getDest() const { return getRawDest()->stripPointerCasts(); }
341 
342  /// This is just like getRawSource, but it strips off any cast
343  /// instructions that feed it, giving the original input. The returned
344  /// value is guaranteed to be a pointer.
345  Value *getSource() const { return getRawSource()->stripPointerCasts(); }
346 
347  unsigned getDestAddressSpace() const {
348  return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
349  }
350 
351  unsigned getSourceAddressSpace() const {
352  return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
353  }
354 
355  /// Set the specified arguments of the instruction.
356  void setDest(Value *Ptr) {
357  assert(getRawDest()->getType() == Ptr->getType() &&
358  "setDest called with pointer of wrong type!");
359  setArgOperand(ARG_DEST, Ptr);
360  }
361 
362  void setSource(Value *Ptr) {
363  assert(getRawSource()->getType() == Ptr->getType() &&
364  "setSource called with pointer of wrong type!");
365  setArgOperand(ARG_SOURCE, Ptr);
366  }
367 
368  void setLength(Value *L) {
369  assert(getLength()->getType() == L->getType() &&
370  "setLength called with value of wrong type!");
371  setArgOperand(ARG_LENGTH, L);
372  }
373 
376  "setElementSizeInBytes called with value of wrong type!");
377  setArgOperand(ARG_ELEMENTSIZE, V);
378  }
379 
380  static inline bool classof(const IntrinsicInst *I) {
381  return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
382  }
383  static inline bool classof(const Value *V) {
384  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
385  }
386  };
387 
388  /// This class represents atomic memset intrinsic
389  /// TODO: Integrate this class into MemIntrinsic hierarchy; for now this is
390  /// C&P of all methods from that hierarchy
392  private:
393  enum { ARG_DEST = 0, ARG_VALUE = 1, ARG_LENGTH = 2, ARG_ELEMENTSIZE = 3 };
394 
395  public:
396  Value *getRawDest() const {
397  return const_cast<Value *>(getArgOperand(ARG_DEST));
398  }
399  const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
400  Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
401 
402  Value *getValue() const { return const_cast<Value*>(getArgOperand(ARG_VALUE)); }
403  const Use &getValueUse() const { return getArgOperandUse(ARG_VALUE); }
404  Use &getValueUse() { return getArgOperandUse(ARG_VALUE); }
405 
406  Value *getLength() const {
407  return const_cast<Value *>(getArgOperand(ARG_LENGTH));
408  }
409  const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
410  Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
411 
412  bool isVolatile() const { return false; }
413 
415  return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
416  }
417 
419  return cast<ConstantInt>(getRawElementSizeInBytes());
420  }
421 
423  return getElementSizeInBytesCst()->getZExtValue();
424  }
425 
426  /// This is just like getRawDest, but it strips off any cast
427  /// instructions that feed it, giving the original input. The returned
428  /// value is guaranteed to be a pointer.
429  Value *getDest() const { return getRawDest()->stripPointerCasts(); }
430 
431  unsigned getDestAddressSpace() const {
432  return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
433  }
434 
435  /// Set the specified arguments of the instruction.
436  void setDest(Value *Ptr) {
437  assert(getRawDest()->getType() == Ptr->getType() &&
438  "setDest called with pointer of wrong type!");
439  setArgOperand(ARG_DEST, Ptr);
440  }
441 
442  void setValue(Value *Val) {
443  assert(getValue()->getType() == Val->getType() &&
444  "setValue called with value of wrong type!");
445  setArgOperand(ARG_VALUE, Val);
446  }
447 
448  void setLength(Value *L) {
449  assert(getLength()->getType() == L->getType() &&
450  "setLength called with value of wrong type!");
451  setArgOperand(ARG_LENGTH, L);
452  }
453 
456  "setElementSizeInBytes called with value of wrong type!");
457  setArgOperand(ARG_ELEMENTSIZE, V);
458  }
459 
460  static inline bool classof(const IntrinsicInst *I) {
461  return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
462  }
463  static inline bool classof(const Value *V) {
464  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
465  }
466  };
467 
468  /// This is the common base class for memset/memcpy/memmove.
469  class MemIntrinsic : public IntrinsicInst {
470  public:
471  Value *getRawDest() const { return const_cast<Value*>(getArgOperand(0)); }
472  const Use &getRawDestUse() const { return getArgOperandUse(0); }
474 
475  Value *getLength() const { return const_cast<Value*>(getArgOperand(2)); }
476  const Use &getLengthUse() const { return getArgOperandUse(2); }
478 
480  return cast<ConstantInt>(const_cast<Value*>(getArgOperand(3)));
481  }
482 
483  unsigned getAlignment() const {
484  return getAlignmentCst()->getZExtValue();
485  }
486 
488  return cast<ConstantInt>(const_cast<Value*>(getArgOperand(4)));
489  }
490 
491  bool isVolatile() const {
492  return !getVolatileCst()->isZero();
493  }
494 
495  unsigned getDestAddressSpace() const {
496  return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
497  }
498 
499  /// This is just like getRawDest, but it strips off any cast
500  /// instructions that feed it, giving the original input. The returned
501  /// value is guaranteed to be a pointer.
502  Value *getDest() const { return getRawDest()->stripPointerCasts(); }
503 
504  /// Set the specified arguments of the instruction.
505  void setDest(Value *Ptr) {
506  assert(getRawDest()->getType() == Ptr->getType() &&
507  "setDest called with pointer of wrong type!");
508  setArgOperand(0, Ptr);
509  }
510 
511  void setLength(Value *L) {
512  assert(getLength()->getType() == L->getType() &&
513  "setLength called with value of wrong type!");
514  setArgOperand(2, L);
515  }
516 
518  setArgOperand(3, A);
519  }
520 
522  setArgOperand(4, V);
523  }
524 
526  return getArgOperand(3)->getType();
527  }
528 
529  // Methods for support type inquiry through isa, cast, and dyn_cast:
530  static bool classof(const IntrinsicInst *I) {
531  switch (I->getIntrinsicID()) {
532  case Intrinsic::memcpy:
533  case Intrinsic::memmove:
534  case Intrinsic::memset:
535  return true;
536  default: return false;
537  }
538  }
539  static bool classof(const Value *V) {
540  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
541  }
542  };
543 
544  /// This class wraps the llvm.memset intrinsic.
545  class MemSetInst : public MemIntrinsic {
546  public:
547  /// Return the arguments to the instruction.
548  Value *getValue() const { return const_cast<Value*>(getArgOperand(1)); }
549  const Use &getValueUse() const { return getArgOperandUse(1); }
550  Use &getValueUse() { return getArgOperandUse(1); }
551 
552  void setValue(Value *Val) {
553  assert(getValue()->getType() == Val->getType() &&
554  "setValue called with value of wrong type!");
555  setArgOperand(1, Val);
556  }
557 
558  // Methods for support type inquiry through isa, cast, and dyn_cast:
559  static bool classof(const IntrinsicInst *I) {
560  return I->getIntrinsicID() == Intrinsic::memset;
561  }
562  static bool classof(const Value *V) {
563  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
564  }
565  };
566 
567  /// This class wraps the llvm.memcpy/memmove intrinsics.
568  class MemTransferInst : public MemIntrinsic {
569  public:
570  /// Return the arguments to the instruction.
571  Value *getRawSource() const { return const_cast<Value*>(getArgOperand(1)); }
572  const Use &getRawSourceUse() const { return getArgOperandUse(1); }
574 
575  /// This is just like getRawSource, but it strips off any cast
576  /// instructions that feed it, giving the original input. The returned
577  /// value is guaranteed to be a pointer.
578  Value *getSource() const { return getRawSource()->stripPointerCasts(); }
579 
580  unsigned getSourceAddressSpace() const {
581  return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
582  }
583 
584  void setSource(Value *Ptr) {
585  assert(getRawSource()->getType() == Ptr->getType() &&
586  "setSource called with pointer of wrong type!");
587  setArgOperand(1, Ptr);
588  }
589 
590  // Methods for support type inquiry through isa, cast, and dyn_cast:
591  static bool classof(const IntrinsicInst *I) {
592  return I->getIntrinsicID() == Intrinsic::memcpy ||
593  I->getIntrinsicID() == Intrinsic::memmove;
594  }
595  static bool classof(const Value *V) {
596  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
597  }
598  };
599 
600  /// This class wraps the llvm.memcpy intrinsic.
601  class MemCpyInst : public MemTransferInst {
602  public:
603  // Methods for support type inquiry through isa, cast, and dyn_cast:
604  static bool classof(const IntrinsicInst *I) {
605  return I->getIntrinsicID() == Intrinsic::memcpy;
606  }
607  static bool classof(const Value *V) {
608  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
609  }
610  };
611 
612  /// This class wraps the llvm.memmove intrinsic.
613  class MemMoveInst : public MemTransferInst {
614  public:
615  // Methods for support type inquiry through isa, cast, and dyn_cast:
616  static bool classof(const IntrinsicInst *I) {
617  return I->getIntrinsicID() == Intrinsic::memmove;
618  }
619  static bool classof(const Value *V) {
620  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
621  }
622  };
623 
624  /// This represents the llvm.va_start intrinsic.
625  class VAStartInst : public IntrinsicInst {
626  public:
627  static bool classof(const IntrinsicInst *I) {
628  return I->getIntrinsicID() == Intrinsic::vastart;
629  }
630  static bool classof(const Value *V) {
631  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
632  }
633 
634  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
635  };
636 
637  /// This represents the llvm.va_end intrinsic.
638  class VAEndInst : public IntrinsicInst {
639  public:
640  static bool classof(const IntrinsicInst *I) {
641  return I->getIntrinsicID() == Intrinsic::vaend;
642  }
643  static bool classof(const Value *V) {
644  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
645  }
646 
647  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
648  };
649 
650  /// This represents the llvm.va_copy intrinsic.
651  class VACopyInst : public IntrinsicInst {
652  public:
653  static bool classof(const IntrinsicInst *I) {
654  return I->getIntrinsicID() == Intrinsic::vacopy;
655  }
656  static bool classof(const Value *V) {
657  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
658  }
659 
660  Value *getDest() const { return const_cast<Value*>(getArgOperand(0)); }
661  Value *getSrc() const { return const_cast<Value*>(getArgOperand(1)); }
662  };
663 
664  /// This represents the llvm.instrprof_increment intrinsic.
666  public:
667  static bool classof(const IntrinsicInst *I) {
668  return I->getIntrinsicID() == Intrinsic::instrprof_increment;
669  }
670  static bool classof(const Value *V) {
671  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
672  }
673 
675  return cast<GlobalVariable>(
676  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
677  }
678 
679  ConstantInt *getHash() const {
680  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
681  }
682 
684  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
685  }
686 
688  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
689  }
690 
691  Value *getStep() const;
692  };
693 
695  public:
696  static bool classof(const IntrinsicInst *I) {
697  return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
698  }
699  static bool classof(const Value *V) {
700  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
701  }
702  };
703 
704  /// This represents the llvm.instrprof_value_profile intrinsic.
706  public:
707  static bool classof(const IntrinsicInst *I) {
708  return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
709  }
710  static bool classof(const Value *V) {
711  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
712  }
713 
715  return cast<GlobalVariable>(
716  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
717  }
718 
719  ConstantInt *getHash() const {
720  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
721  }
722 
724  return cast<Value>(const_cast<Value *>(getArgOperand(2)));
725  }
726 
728  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
729  }
730 
731  // Returns the value site index.
733  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
734  }
735  };
736 
737 } // end namespace llvm
738 
739 #endif // LLVM_IR_INTRINSICINST_H
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
static bool classof(const Value *V)
IntrinsicInst & operator=(const IntrinsicInst &)=delete
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions that feed it, giving the original input.
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
Value * getSrc() const
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
unsigned getDestAddressSpace() const
This represents the llvm.va_end intrinsic.
static bool classof(const Value *V)
ConstantInt * getElementSizeInBytesCst() const
const Use & getValueUse() const
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
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
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:697
This class wraps the llvm.memset intrinsic.
void setVolatile(Constant *V)
void setValue(Value *Val)
static bool classof(const IntrinsicInst *I)
This is the common base class for constrained floating point intrinsics.
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
void setAlignment(Constant *A)
Metadata * getRawVariable() const
Value * getArgList() const
static bool classof(const IntrinsicInst *I)
Definition: IntrinsicInst.h:75
DIExpression * getExpression() const
Value * getRawSource() const
Return the arguments to the instruction.
Metadata * getRawExpression() const
This class wraps the llvm.memmove intrinsic.
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Value * getRawSource() const
Return the arguments to the instruction.
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
This represents the llvm.va_start intrinsic.
unsigned getSourceAddressSpace() const
DILocalVariable * getVariable() const
Definition: IntrinsicInst.h:93
static bool classof(const Value *V)
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:190
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
static bool classof(const Value *V)
GlobalVariable * getName() const
ConstantInt * getNumCounters() const
static bool classof(const Value *V)
ConstantInt * getHash() const
const Use & getLengthUse() const
static bool classof(const Value *V)
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
Value * getAddress() const
Definition: IntrinsicInst.h:91
This is an important base class in LLVM.
Definition: Constant.h:42
ConstantInt * getElementSizeInBytesCst() const
Value * getValue() const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
#define A
Definition: LargeTest.cpp:12
static bool classof(const Value *V)
Value * getRawDest() const
Metadata * getRawExpression() const
static bool classof(const Value *V)
Definition: IntrinsicInst.h:83
DIExpression * getExpression() const
Definition: IntrinsicInst.h:97
uint64_t getOffset() const
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
Definition: Value.cpp:527
static bool classof(const IntrinsicInst *I)
Type * getAlignmentType() const
bool isVolatile() const
ConstantInt * getVolatileCst() 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.
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions that feed it, giving the original input.
This is the shared class of boolean and integer constants.
Definition: Constants.h:84
Value * getArgList() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
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.
static bool classof(const Value *V)
This class represents atomic memset intrinsic TODO: Integrate this class into MemIntrinsic hierarchy;...
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:167
This class represents atomic memcpy intrinsic TODO: Integrate this class into MemIntrinsic hierarchy;...
static bool classof(const Value *V)
ConstantInt * getAlignmentCst() const
static bool classof(const IntrinsicInst *I)
Value * getDest() const
Metadata * getRawVariable() const
void setLength(Value *L)
This represents the llvm.instrprof_increment intrinsic.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
This class wraps the llvm.memcpy/memmove intrinsics.
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
This represents the llvm.dbg.value instruction.
ConstantInt * getHash() const
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions that feed it, giving the original input.
#define I(x, y, z)
Definition: MD5.cpp:58
void setArgOperand(unsigned i, Value *v)
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
void setSource(Value *Ptr)
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions that feed it, giving the original input.
static bool classof(const Value *V)
Value * getValue() const
Return the arguments to the instruction.
static bool classof(const Value *V)
Definition: IntrinsicInst.h:61
unsigned getAlignment() const
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_copy intrinsic.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * getLength() const
LLVM Value Representation.
Definition: Value.h:73
ConstantInt * getElementSizeInBytesCst() const
GlobalVariable * getName() const
Value * getRawSource() const
Return the arguments to the instruction.
static bool classof(const Value *V)
ConstantInt * getValueKind() const
static bool classof(const Value *V)
DILocalVariable * getVariable() const
int * Ptr
const Use & getRawDestUse() const
This represents the llvm.instrprof_value_profile intrinsic.
const Use & getRawSourceUse() const
This represents the llvm.dbg.declare instruction.
Definition: IntrinsicInst.h:89
Root of the metadata hierarchy.
Definition: Metadata.h:58
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:174
static bool classof(const IntrinsicInst *I)
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