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_fptrunc:
242  case Intrinsic::experimental_constrained_fpext:
243  case Intrinsic::experimental_constrained_sqrt:
244  case Intrinsic::experimental_constrained_pow:
245  case Intrinsic::experimental_constrained_powi:
246  case Intrinsic::experimental_constrained_sin:
247  case Intrinsic::experimental_constrained_cos:
248  case Intrinsic::experimental_constrained_exp:
249  case Intrinsic::experimental_constrained_exp2:
250  case Intrinsic::experimental_constrained_log:
251  case Intrinsic::experimental_constrained_log10:
252  case Intrinsic::experimental_constrained_log2:
253  case Intrinsic::experimental_constrained_rint:
254  case Intrinsic::experimental_constrained_nearbyint:
255  case Intrinsic::experimental_constrained_maxnum:
256  case Intrinsic::experimental_constrained_minnum:
257  case Intrinsic::experimental_constrained_ceil:
258  case Intrinsic::experimental_constrained_floor:
259  case Intrinsic::experimental_constrained_round:
260  case Intrinsic::experimental_constrained_trunc:
261  return true;
262  default: return false;
263  }
264  }
265  static bool classof(const Value *V) {
266  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
267  }
268  };
269 
270  /// This class represents a op.with.overflow intrinsic.
272  public:
273  static bool classof(const IntrinsicInst *I) {
274  switch (I->getIntrinsicID()) {
275  case Intrinsic::uadd_with_overflow:
276  case Intrinsic::sadd_with_overflow:
277  case Intrinsic::usub_with_overflow:
278  case Intrinsic::ssub_with_overflow:
279  case Intrinsic::umul_with_overflow:
280  case Intrinsic::smul_with_overflow:
281  return true;
282  default:
283  return false;
284  }
285  }
286  static bool classof(const Value *V) {
287  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
288  }
289 
290  Value *getLHS() const { return const_cast<Value*>(getArgOperand(0)); }
291  Value *getRHS() const { return const_cast<Value*>(getArgOperand(1)); }
292 
293  /// Returns the binary operation underlying the intrinsic.
294  Instruction::BinaryOps getBinaryOp() const;
295 
296  /// Whether the intrinsic is signed or unsigned.
297  bool isSigned() const;
298 
299  /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
300  unsigned getNoWrapKind() const;
301  };
302 
303  /// Common base class for all memory intrinsics. Simply provides
304  /// common methods.
305  /// Written as CRTP to avoid a common base class amongst the
306  /// three atomicity hierarchies.
307  template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
308  private:
309  enum { ARG_DEST = 0, ARG_LENGTH = 2 };
310 
311  public:
312  Value *getRawDest() const {
313  return const_cast<Value *>(getArgOperand(ARG_DEST));
314  }
315  const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
316  Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
317 
318  Value *getLength() const {
319  return const_cast<Value *>(getArgOperand(ARG_LENGTH));
320  }
321  const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
322  Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
323 
324  /// This is just like getRawDest, but it strips off any cast
325  /// instructions (including addrspacecast) that feed it, giving the
326  /// original input. The returned value is guaranteed to be a pointer.
327  Value *getDest() const { return getRawDest()->stripPointerCasts(); }
328 
329  unsigned getDestAddressSpace() const {
330  return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
331  }
332 
333  unsigned getDestAlignment() const { return getParamAlignment(ARG_DEST); }
334 
335  /// Set the specified arguments of the instruction.
336  void setDest(Value *Ptr) {
337  assert(getRawDest()->getType() == Ptr->getType() &&
338  "setDest called with pointer of wrong type!");
339  setArgOperand(ARG_DEST, Ptr);
340  }
341 
342  void setDestAlignment(unsigned Align) {
343  removeParamAttr(ARG_DEST, Attribute::Alignment);
344  if (Align > 0)
345  addParamAttr(ARG_DEST,
347  }
348 
349  void setLength(Value *L) {
350  assert(getLength()->getType() == L->getType() &&
351  "setLength called with value of wrong type!");
352  setArgOperand(ARG_LENGTH, L);
353  }
354  };
355 
356  /// Common base class for all memory transfer intrinsics. Simply provides
357  /// common methods.
358  template <class BaseCL> class MemTransferBase : public BaseCL {
359  private:
360  enum { ARG_SOURCE = 1 };
361 
362  public:
363  /// Return the arguments to the instruction.
364  Value *getRawSource() const {
365  return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
366  }
367  const Use &getRawSourceUse() const {
368  return BaseCL::getArgOperandUse(ARG_SOURCE);
369  }
370  Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
371 
372  /// This is just like getRawSource, but it strips off any cast
373  /// instructions that feed it, giving the original input. The returned
374  /// value is guaranteed to be a pointer.
375  Value *getSource() const { return getRawSource()->stripPointerCasts(); }
376 
377  unsigned getSourceAddressSpace() const {
378  return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
379  }
380 
381  unsigned getSourceAlignment() const {
382  return BaseCL::getParamAlignment(ARG_SOURCE);
383  }
384 
385  void setSource(Value *Ptr) {
386  assert(getRawSource()->getType() == Ptr->getType() &&
387  "setSource called with pointer of wrong type!");
388  BaseCL::setArgOperand(ARG_SOURCE, Ptr);
389  }
390 
391  void setSourceAlignment(unsigned Align) {
392  BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
393  if (Align > 0)
394  BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
395  BaseCL::getContext(), Align));
396  }
397  };
398 
399  /// Common base class for all memset intrinsics. Simply provides
400  /// common methods.
401  template <class BaseCL> class MemSetBase : public BaseCL {
402  private:
403  enum { ARG_VALUE = 1 };
404 
405  public:
406  Value *getValue() const {
407  return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
408  }
409  const Use &getValueUse() const {
410  return BaseCL::getArgOperandUse(ARG_VALUE);
411  }
412  Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
413 
414  void setValue(Value *Val) {
415  assert(getValue()->getType() == Val->getType() &&
416  "setValue called with value of wrong type!");
417  BaseCL::setArgOperand(ARG_VALUE, Val);
418  }
419  };
420 
421  // The common base class for the atomic memset/memmove/memcpy intrinsics
422  // i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
423  class AtomicMemIntrinsic : public MemIntrinsicBase<AtomicMemIntrinsic> {
424  private:
425  enum { ARG_ELEMENTSIZE = 3 };
426 
427  public:
429  return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
430  }
431 
433  return cast<ConstantInt>(getRawElementSizeInBytes());
434  }
435 
437  return getElementSizeInBytesCst()->getZExtValue();
438  }
439 
442  "setElementSizeInBytes called with value of wrong type!");
443  setArgOperand(ARG_ELEMENTSIZE, V);
444  }
445 
446  static bool classof(const IntrinsicInst *I) {
447  switch (I->getIntrinsicID()) {
448  case Intrinsic::memcpy_element_unordered_atomic:
449  case Intrinsic::memmove_element_unordered_atomic:
450  case Intrinsic::memset_element_unordered_atomic:
451  return true;
452  default:
453  return false;
454  }
455  }
456  static bool classof(const Value *V) {
457  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
458  }
459  };
460 
461  /// This class represents atomic memset intrinsic
462  // i.e. llvm.element.unordered.atomic.memset
463  class AtomicMemSetInst : public MemSetBase<AtomicMemIntrinsic> {
464  public:
465  static bool classof(const IntrinsicInst *I) {
466  return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
467  }
468  static bool classof(const Value *V) {
469  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
470  }
471  };
472 
473  // This class wraps the atomic memcpy/memmove intrinsics
474  // i.e. llvm.element.unordered.atomic.memcpy/memmove
475  class AtomicMemTransferInst : public MemTransferBase<AtomicMemIntrinsic> {
476  public:
477  static bool classof(const IntrinsicInst *I) {
478  switch (I->getIntrinsicID()) {
479  case Intrinsic::memcpy_element_unordered_atomic:
480  case Intrinsic::memmove_element_unordered_atomic:
481  return true;
482  default:
483  return false;
484  }
485  }
486  static bool classof(const Value *V) {
487  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
488  }
489  };
490 
491  /// This class represents the atomic memcpy intrinsic
492  /// i.e. llvm.element.unordered.atomic.memcpy
494  public:
495  static bool classof(const IntrinsicInst *I) {
496  return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
497  }
498  static bool classof(const Value *V) {
499  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
500  }
501  };
502 
503  /// This class represents the atomic memmove intrinsic
504  /// i.e. llvm.element.unordered.atomic.memmove
506  public:
507  static bool classof(const IntrinsicInst *I) {
508  return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
509  }
510  static bool classof(const Value *V) {
511  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
512  }
513  };
514 
515  /// This is the common base class for memset/memcpy/memmove.
516  class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
517  private:
518  enum { ARG_VOLATILE = 3 };
519 
520  public:
522  return cast<ConstantInt>(
523  const_cast<Value *>(getArgOperand(ARG_VOLATILE)));
524  }
525 
526  bool isVolatile() const {
527  return !getVolatileCst()->isZero();
528  }
529 
530  void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
531 
532  // Methods for support type inquiry through isa, cast, and dyn_cast:
533  static bool classof(const IntrinsicInst *I) {
534  switch (I->getIntrinsicID()) {
535  case Intrinsic::memcpy:
536  case Intrinsic::memmove:
537  case Intrinsic::memset:
538  return true;
539  default: return false;
540  }
541  }
542  static bool classof(const Value *V) {
543  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
544  }
545  };
546 
547  /// This class wraps the llvm.memset intrinsic.
548  class MemSetInst : public MemSetBase<MemIntrinsic> {
549  public:
550  // Methods for support type inquiry through isa, cast, and dyn_cast:
551  static bool classof(const IntrinsicInst *I) {
552  return I->getIntrinsicID() == Intrinsic::memset;
553  }
554  static bool classof(const Value *V) {
555  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
556  }
557  };
558 
559  /// This class wraps the llvm.memcpy/memmove intrinsics.
560  class MemTransferInst : public MemTransferBase<MemIntrinsic> {
561  public:
562  // Methods for support type inquiry through isa, cast, and dyn_cast:
563  static bool classof(const IntrinsicInst *I) {
564  return I->getIntrinsicID() == Intrinsic::memcpy ||
565  I->getIntrinsicID() == Intrinsic::memmove;
566  }
567  static bool classof(const Value *V) {
568  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
569  }
570  };
571 
572  /// This class wraps the llvm.memcpy intrinsic.
573  class MemCpyInst : public MemTransferInst {
574  public:
575  // Methods for support type inquiry through isa, cast, and dyn_cast:
576  static bool classof(const IntrinsicInst *I) {
577  return I->getIntrinsicID() == Intrinsic::memcpy;
578  }
579  static bool classof(const Value *V) {
580  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
581  }
582  };
583 
584  /// This class wraps the llvm.memmove intrinsic.
585  class MemMoveInst : public MemTransferInst {
586  public:
587  // Methods for support type inquiry through isa, cast, and dyn_cast:
588  static bool classof(const IntrinsicInst *I) {
589  return I->getIntrinsicID() == Intrinsic::memmove;
590  }
591  static bool classof(const Value *V) {
592  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
593  }
594  };
595 
596  // The common base class for any memset/memmove/memcpy intrinsics;
597  // whether they be atomic or non-atomic.
598  // i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
599  // and llvm.memset/memcpy/memmove
600  class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
601  public:
602  bool isVolatile() const {
603  // Only the non-atomic intrinsics can be volatile
604  if (auto *MI = dyn_cast<MemIntrinsic>(this))
605  return MI->isVolatile();
606  return false;
607  }
608 
609  static bool classof(const IntrinsicInst *I) {
610  switch (I->getIntrinsicID()) {
611  case Intrinsic::memcpy:
612  case Intrinsic::memmove:
613  case Intrinsic::memset:
614  case Intrinsic::memcpy_element_unordered_atomic:
615  case Intrinsic::memmove_element_unordered_atomic:
616  case Intrinsic::memset_element_unordered_atomic:
617  return true;
618  default:
619  return false;
620  }
621  }
622  static bool classof(const Value *V) {
623  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
624  }
625  };
626 
627  /// This class represents any memset intrinsic
628  // i.e. llvm.element.unordered.atomic.memset
629  // and llvm.memset
630  class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
631  public:
632  static bool classof(const IntrinsicInst *I) {
633  switch (I->getIntrinsicID()) {
634  case Intrinsic::memset:
635  case Intrinsic::memset_element_unordered_atomic:
636  return true;
637  default:
638  return false;
639  }
640  }
641  static bool classof(const Value *V) {
642  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
643  }
644  };
645 
646  // This class wraps any memcpy/memmove intrinsics
647  // i.e. llvm.element.unordered.atomic.memcpy/memmove
648  // and llvm.memcpy/memmove
649  class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
650  public:
651  static bool classof(const IntrinsicInst *I) {
652  switch (I->getIntrinsicID()) {
653  case Intrinsic::memcpy:
654  case Intrinsic::memmove:
655  case Intrinsic::memcpy_element_unordered_atomic:
656  case Intrinsic::memmove_element_unordered_atomic:
657  return true;
658  default:
659  return false;
660  }
661  }
662  static bool classof(const Value *V) {
663  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
664  }
665  };
666 
667  /// This class represents any memcpy intrinsic
668  /// i.e. llvm.element.unordered.atomic.memcpy
669  /// and llvm.memcpy
671  public:
672  static bool classof(const IntrinsicInst *I) {
673  switch (I->getIntrinsicID()) {
674  case Intrinsic::memcpy:
675  case Intrinsic::memcpy_element_unordered_atomic:
676  return true;
677  default:
678  return false;
679  }
680  }
681  static bool classof(const Value *V) {
682  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
683  }
684  };
685 
686  /// This class represents any memmove intrinsic
687  /// i.e. llvm.element.unordered.atomic.memmove
688  /// and llvm.memmove
690  public:
691  static bool classof(const IntrinsicInst *I) {
692  switch (I->getIntrinsicID()) {
693  case Intrinsic::memmove:
694  case Intrinsic::memmove_element_unordered_atomic:
695  return true;
696  default:
697  return false;
698  }
699  }
700  static bool classof(const Value *V) {
701  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
702  }
703  };
704 
705  /// This represents the llvm.va_start intrinsic.
706  class VAStartInst : public IntrinsicInst {
707  public:
708  static bool classof(const IntrinsicInst *I) {
709  return I->getIntrinsicID() == Intrinsic::vastart;
710  }
711  static bool classof(const Value *V) {
712  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
713  }
714 
715  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
716  };
717 
718  /// This represents the llvm.va_end intrinsic.
719  class VAEndInst : public IntrinsicInst {
720  public:
721  static bool classof(const IntrinsicInst *I) {
722  return I->getIntrinsicID() == Intrinsic::vaend;
723  }
724  static bool classof(const Value *V) {
725  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
726  }
727 
728  Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
729  };
730 
731  /// This represents the llvm.va_copy intrinsic.
732  class VACopyInst : public IntrinsicInst {
733  public:
734  static bool classof(const IntrinsicInst *I) {
735  return I->getIntrinsicID() == Intrinsic::vacopy;
736  }
737  static bool classof(const Value *V) {
738  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
739  }
740 
741  Value *getDest() const { return const_cast<Value*>(getArgOperand(0)); }
742  Value *getSrc() const { return const_cast<Value*>(getArgOperand(1)); }
743  };
744 
745  /// This represents the llvm.instrprof_increment intrinsic.
747  public:
748  static bool classof(const IntrinsicInst *I) {
749  return I->getIntrinsicID() == Intrinsic::instrprof_increment;
750  }
751  static bool classof(const Value *V) {
752  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
753  }
754 
756  return cast<GlobalVariable>(
757  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
758  }
759 
760  ConstantInt *getHash() const {
761  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
762  }
763 
765  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
766  }
767 
769  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
770  }
771 
772  Value *getStep() const;
773  };
774 
776  public:
777  static bool classof(const IntrinsicInst *I) {
778  return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
779  }
780  static bool classof(const Value *V) {
781  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
782  }
783  };
784 
785  /// This represents the llvm.instrprof_value_profile intrinsic.
787  public:
788  static bool classof(const IntrinsicInst *I) {
789  return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
790  }
791  static bool classof(const Value *V) {
792  return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
793  }
794 
796  return cast<GlobalVariable>(
797  const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
798  }
799 
800  ConstantInt *getHash() const {
801  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
802  }
803 
805  return cast<Value>(const_cast<Value *>(getArgOperand(2)));
806  }
807 
809  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
810  }
811 
812  // Returns the value site index.
814  return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
815  }
816  };
817 
818 } // end namespace llvm
819 
820 #endif // LLVM_IR_INTRINSICINST_H
static bool classof(const Value *V)
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)
Value * getRHS() const
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
This class represents a op.with.overflow intrinsic.
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:1223
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:1550
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:1218
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:1374
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)
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:1264
#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:1229
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Definition: InstrTypes.h:1404
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
Value * getLHS() const
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