LLVM  9.0.0svn
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"
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>
37 
38 namespace llvm {
39 
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;
48 
49  /// Return the intrinsic ID of this intrinsic.
52  }
53 
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;
59  }
60  static bool classof(const Value *V) {
61  return isa<CallInst>(V) && classof(cast<CallInst>(V));
62  }
63  };
64 
65  /// This is the common base class for debug info intrinsics.
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;
78  }
79  }
80  static bool classof(const Value *V) {
81  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
82  }
83  /// @}
84  };
85 
86  /// This is the common base class for debug info intrinsics for variables.
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;
93 
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;
98  }
99 
101  return cast<DILocalVariable>(getRawVariable());
102  }
103 
105  return cast<DIExpression>(getRawExpression());
106  }
107 
109  return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
110  }
111 
113  return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
114  }
115 
116  /// Get the size (in bits) of the variable, or fragment of the variable that
117  /// is described.
118  Optional<uint64_t> getFragmentSizeInBits() const;
119 
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;
129  }
130  }
131  static bool classof(const Value *V) {
132  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
133  }
134  /// @}
135  };
136 
137  /// This represents the llvm.dbg.declare instruction.
139  public:
140  Value *getAddress() const { return getVariableLocation(); }
141 
142  /// \name Casting methods
143  /// @{
144  static bool classof(const IntrinsicInst *I) {
145  return I->getIntrinsicID() == Intrinsic::dbg_declare;
146  }
147  static bool classof(const Value *V) {
148  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
149  }
150  /// @}
151  };
152 
153  /// This represents the llvm.dbg.addr instruction.
155  public:
156  Value *getAddress() const { return getVariableLocation(); }
157 
158  /// \name Casting methods
159  /// @{
160  static bool classof(const IntrinsicInst *I) {
161  return I->getIntrinsicID() == Intrinsic::dbg_addr;
162  }
163  static bool classof(const Value *V) {
164  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
165  }
166  };
167 
168  /// This represents the llvm.dbg.value instruction.
170  public:
171  Value *getValue() const {
172  return getVariableLocation(/* AllowNullOp = */ false);
173  }
174 
175  /// \name Casting methods
176  /// @{
177  static bool classof(const IntrinsicInst *I) {
178  return I->getIntrinsicID() == Intrinsic::dbg_value;
179  }
180  static bool classof(const Value *V) {
181  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
182  }
183  /// @}
184  };
185 
186  /// This represents the llvm.dbg.label instruction.
188  public:
189  DILabel *getLabel() const {
190  return cast<DILabel>(getRawLabel());
191  }
192 
194  return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
195  }
196 
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;
201  }
202  static bool classof(const Value *V) {
203  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
204  }
205  /// @}
206  };
207 
208  /// This is the common base class for constrained floating point intrinsics.
210  public:
217  rmTowardZero
218  };
219 
224  ebStrict
225  };
226 
227  bool isUnaryOp() const;
228  bool isTernaryOp() const;
229  RoundingMode getRoundingMode() const;
230  ExceptionBehavior getExceptionBehavior() const;
231 
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;
261  }
262  }
263  static bool classof(const Value *V) {
264  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
265  }
266  };
267 
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 };
275 
276  public:
277  Value *getRawDest() const {
278  return const_cast<Value *>(getArgOperand(ARG_DEST));
279  }
280  const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
281  Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
282 
283  Value *getLength() const {
284  return const_cast<Value *>(getArgOperand(ARG_LENGTH));
285  }
286  const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
287  Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
288 
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(); }
293 
294  unsigned getDestAddressSpace() const {
295  return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
296  }
297 
298  unsigned getDestAlignment() const { return getParamAlignment(ARG_DEST); }
299 
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);
305  }
306 
307  void setDestAlignment(unsigned Align) {
308  removeParamAttr(ARG_DEST, Attribute::Alignment);
309  if (Align > 0)
310  addParamAttr(ARG_DEST,
312  }
313 
314  void setLength(Value *L) {
315  assert(getLength()->getType() == L->getType() &&
316  "setLength called with value of wrong type!");
317  setArgOperand(ARG_LENGTH, L);
318  }
319  };
320 
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 };
326 
327  public:
328  /// Return the arguments to the instruction.
329  Value *getRawSource() const {
330  return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
331  }
332  const Use &getRawSourceUse() const {
333  return BaseCL::getArgOperandUse(ARG_SOURCE);
334  }
335  Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
336 
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(); }
341 
342  unsigned getSourceAddressSpace() const {
343  return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
344  }
345 
346  unsigned getSourceAlignment() const {
347  return BaseCL::getParamAlignment(ARG_SOURCE);
348  }
349 
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);
354  }
355 
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));
361  }
362  };
363 
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 };
369 
370  public:
371  Value *getValue() const {
372  return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
373  }
374  const Use &getValueUse() const {
375  return BaseCL::getArgOperandUse(ARG_VALUE);
376  }
377  Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
378 
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);
383  }
384  };
385 
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 };
391 
392  public:
394  return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
395  }
396 
398  return cast<ConstantInt>(getRawElementSizeInBytes());
399  }
400 
402  return getElementSizeInBytesCst()->getZExtValue();
403  }
404 
407  "setElementSizeInBytes called with value of wrong type!");
408  setArgOperand(ARG_ELEMENTSIZE, V);
409  }
410 
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;
419  }
420  }
421  static bool classof(const Value *V) {
422  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
423  }
424  };
425 
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;
432  }
433  static bool classof(const Value *V) {
434  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
435  }
436  };
437 
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;
449  }
450  }
451  static bool classof(const Value *V) {
452  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
453  }
454  };
455 
456  /// This class represents the atomic memcpy intrinsic
457  /// i.e. llvm.element.unordered.atomic.memcpy
459  public:
460  static bool classof(const IntrinsicInst *I) {
461  return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
462  }
463  static bool classof(const Value *V) {
464  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
465  }
466  };
467 
468  /// This class represents the atomic memmove intrinsic
469  /// i.e. llvm.element.unordered.atomic.memmove
471  public:
472  static bool classof(const IntrinsicInst *I) {
473  return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
474  }
475  static bool classof(const Value *V) {
476  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
477  }
478  };
479 
480  /// This is the common base class for memset/memcpy/memmove.
481  class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
482  private:
483  enum { ARG_VOLATILE = 3 };
484 
485  public:
487  return cast<ConstantInt>(
488  const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
489  }
490 
491  bool isVolatile() const {
492  return !getVolatileCst()->isZero();
493  }
494 
495  void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
496 
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;
505  }
506  }
507  static bool classof(const Value *V) {
508  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
509  }
510  };
511 
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;
518  }
519  static bool classof(const Value *V) {
520  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
521  }
522  };
523 
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;
531  }
532  static bool classof(const Value *V) {
533  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
534  }
535  };
536 
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;
543  }
544  static bool classof(const Value *V) {
545  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
546  }
547  };
548 
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;
555  }
556  static bool classof(const Value *V) {
557  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
558  }
559  };
560 
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;
572  }
573 
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;
585  }
586  }
587  static bool classof(const Value *V) {
588  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
589  }
590  };
591 
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;
604  }
605  }
606  static bool classof(const Value *V) {
607  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
608  }
609  };
610 
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;
625  }
626  }
627  static bool classof(const Value *V) {
628  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
629  }
630  };
631 
632  /// This class represents any memcpy intrinsic
633  /// i.e. llvm.element.unordered.atomic.memcpy
634  /// and llvm.memcpy
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;
644  }
645  }
646  static bool classof(const Value *V) {
647  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
648  }
649  };
650 
651  /// This class represents any memmove intrinsic
652  /// i.e. llvm.element.unordered.atomic.memmove
653  /// and llvm.memmove
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;
663  }
664  }
665  static bool classof(const Value *V) {
666  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
667  }
668  };
669 
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;
675  }
676  static bool classof(const Value *V) {
677  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
678  }
679 
680  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
681  };
682 
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;
688  }
689  static bool classof(const Value *V) {
690  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
691  }
692 
693  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
694  };
695 
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;
701  }
702  static bool classof(const Value *V) {
703  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
704  }
705 
706  Value *getDest() const { return const_cast<Value*>(getArgOperand(0)); }
707  Value *getSrc() const { return const_cast<Value*>(getArgOperand(1)); }
708  };
709 
710  /// This represents the llvm.instrprof_increment intrinsic.
712  public:
713  static bool classof(const IntrinsicInst *I) {
714  return I->getIntrinsicID() == Intrinsic::instrprof_increment;
715  }
716  static bool classof(const Value *V) {
717  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
718  }
719 
721  return cast<GlobalVariable>(
722  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
723  }
724 
725  ConstantInt *getHash() const {
726  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
727  }
728 
730  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
731  }
732 
734  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
735  }
736 
737  Value *getStep() const;
738  };
739 
741  public:
742  static bool classof(const IntrinsicInst *I) {
743  return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
744  }
745  static bool classof(const Value *V) {
746  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
747  }
748  };
749 
750  /// This represents the llvm.instrprof_value_profile intrinsic.
752  public:
753  static bool classof(const IntrinsicInst *I) {
754  return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
755  }
756  static bool classof(const Value *V) {
757  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
758  }
759 
761  return cast<GlobalVariable>(
762  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
763  }
764 
765  ConstantInt *getHash() const {
766  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
767  }
768 
770  return cast<Value>(const_cast<Value *>(getArgOperand(2)));
771  }
772 
774  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
775  }
776 
777  // Returns the value site index.
779  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
780  }
781  };
782 
783 } // end namespace llvm
784 
785 #endif // LLVM_IR_INTRINSICINST_H
static bool classof(const Value *V)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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)
This represents the llvm.dbg.label instruction.
Value * getSrc() const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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
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:55
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:709
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)
void setArgOperand(unsigned i, Value *v)
Definition: InstrTypes.h:1160
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
This is the common base class for constrained floating point intrinsics.
Value * getLength() const
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: InstrTypes.h:1487
Value * getArgList() const
static bool classof(const IntrinsicInst *I)
Definition: IntrinsicInst.h:70
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions (including addrspacecast) that ...
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1155
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:55
DILabel * getLabel() const
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:244
This represents the llvm.va_start intrinsic.
const Use & getRawSourceUse() const
void setLength(Value *L)
static bool classof(const Value *V)
This is the common base class for debug info intrinsics for variables.
Definition: IntrinsicInst.h:87
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:234
static bool classof(const Value *V)
GlobalVariable * getName() const
ConstantInt * getNumCounters() const
static bool classof(const Value *V)
static bool classof(const Value *V)
static bool classof(const Value *V)
const Use & getValueUse() const
ConstantInt * getHash() const
static bool classof(const Value *V)
This class represents the atomic memmove intrinsic i.e.
Metadata * getRawExpression() const
static bool classof(const Value *V)
static bool classof(const Value *V)
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
Value * getAddress() const
This is an important base class in LLVM.
Definition: Constant.h:41
Value * getValue() const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool classof(const Value *V)
DIExpression * getExpression() const
Metadata * getRawLabel() const
static bool classof(const IntrinsicInst *I)
This class represents any memset intrinsic.
static bool classof(const Value *V)
Definition: IntrinsicInst.h:80
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:529
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:50
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1311
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:83
Value * getArgList() const
void setValue(Value *Val)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Metadata * getRawVariable() const
This is the common base class for debug info intrinsics.
Definition: IntrinsicInst.h:66
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:193
static bool classof(const Value *V)
Value * getDest() const
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.
bool isAddressOfVariable() const
Does this describe the address of a local variable.
Definition: IntrinsicInst.h:96
ConstantInt * getHash() const
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
Definition: InstrTypes.h:1201
#define I(x, y, z)
Definition: MD5.cpp:58
static bool classof(const Value *V)
static bool classof(const Value *V)
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Definition: InstrTypes.h:1166
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Definition: InstrTypes.h:1341
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
Common base class for all memory intrinsics.
DILocalVariable * getVariable() const
static bool classof(const Value *V)
Definition: IntrinsicInst.h:60
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_copy intrinsic.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool classof(const Value *V)
LLVM Value Representation.
Definition: Value.h:72
static bool classof(const IntrinsicInst *I)
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:57
static bool classof(const IntrinsicInst *I)
bool isUnaryOp() const
Definition: Instruction.h:129
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:173
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:43
Value * getAddress() const