LCOV - code coverage report
Current view: top level - include/llvm/IR - IntrinsicInst.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 83 83 100.0 %
Date: 2017-09-14 15:23:50 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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.
      51             :     Intrinsic::ID getIntrinsicID() const {
      52   108530028 :       return getCalledFunction()->getIntrinsicID();
      53             :     }
      54             : 
      55             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
      56             :     static bool classof(const CallInst *I) {
      57   105697075 :       if (const Function *CF = I->getCalledFunction())
      58   105697075 :         return CF->isIntrinsic();
      59             :       return false;
      60             :     }
      61             :     static bool classof(const Value *V) {
      62   576090173 :       return isa<CallInst>(V) && classof(cast<CallInst>(V));
      63             :     }
      64             :   };
      65             : 
      66             :   /// This is the common base class for debug info intrinsics.
      67             :   class DbgInfoIntrinsic : public IntrinsicInst {
      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             :     DILocalVariable *getVariable() const {
      75      136906 :       return cast<DILocalVariable>(getRawVariable());
      76             :     }
      77             : 
      78             :     DIExpression *getExpression() const {
      79      111612 :       return cast<DIExpression>(getRawExpression());
      80             :     }
      81             : 
      82             :     Metadata *getRawVariable() const {
      83      252087 :       return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
      84             :     }
      85             : 
      86             :     Metadata *getRawExpression() const {
      87      214140 :       return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
      88             :     }
      89             : 
      90             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
      91             :     static bool classof(const IntrinsicInst *I) {
      92     7138476 :       switch (I->getIntrinsicID()) {
      93             :       case Intrinsic::dbg_declare:
      94             :       case Intrinsic::dbg_value:
      95             :         return true;
      96             :       default: return false;
      97             :       }
      98             :     }
      99             :     static bool classof(const Value *V) {
     100    92940780 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     101             :     }
     102             :   };
     103             : 
     104             :   /// This represents the llvm.dbg.declare instruction.
     105             :   class DbgDeclareInst : public DbgInfoIntrinsic {
     106             :   public:
     107       41664 :     Value *getAddress() const { return getVariableLocation(); }
     108             : 
     109             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     110             :     static bool classof(const IntrinsicInst *I) {
     111     3478307 :       return I->getIntrinsicID() == Intrinsic::dbg_declare;
     112             :     }
     113             :     static bool classof(const Value *V) {
     114    42837252 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     115             :     }
     116             :   };
     117             : 
     118             :   /// This represents the llvm.dbg.value instruction.
     119             :   class DbgValueInst : public DbgInfoIntrinsic {
     120             :   public:
     121             :     Value *getValue() const {
     122      819888 :       return getVariableLocation(/* AllowNullOp = */ false);
     123             :     }
     124             : 
     125             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     126             :     static bool classof(const IntrinsicInst *I) {
     127     2510440 :       return I->getIntrinsicID() == Intrinsic::dbg_value;
     128             :     }
     129             :     static bool classof(const Value *V) {
     130    26282124 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     131             :     }
     132             :   };
     133             : 
     134             :   /// This is the common base class for constrained floating point intrinsics.
     135             :   class ConstrainedFPIntrinsic : public IntrinsicInst {
     136             :   public:
     137             :     enum RoundingMode {
     138             :       rmInvalid,
     139             :       rmDynamic,
     140             :       rmToNearest,
     141             :       rmDownward,
     142             :       rmUpward,
     143             :       rmTowardZero
     144             :     };
     145             : 
     146             :     enum ExceptionBehavior {
     147             :       ebInvalid,
     148             :       ebIgnore,
     149             :       ebMayTrap,
     150             :       ebStrict
     151             :     };
     152             : 
     153             :     bool isUnaryOp() const;
     154             :     bool isTernaryOp() const;
     155             :     RoundingMode getRoundingMode() const;
     156             :     ExceptionBehavior getExceptionBehavior() const;
     157             : 
     158             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     159             :     static bool classof(const IntrinsicInst *I) {
     160             :       switch (I->getIntrinsicID()) {
     161             :       case Intrinsic::experimental_constrained_fadd:
     162             :       case Intrinsic::experimental_constrained_fsub:
     163             :       case Intrinsic::experimental_constrained_fmul:
     164             :       case Intrinsic::experimental_constrained_fdiv:
     165             :       case Intrinsic::experimental_constrained_frem:
     166             :       case Intrinsic::experimental_constrained_fma:
     167             :       case Intrinsic::experimental_constrained_sqrt:
     168             :       case Intrinsic::experimental_constrained_pow:
     169             :       case Intrinsic::experimental_constrained_powi:
     170             :       case Intrinsic::experimental_constrained_sin:
     171             :       case Intrinsic::experimental_constrained_cos:
     172             :       case Intrinsic::experimental_constrained_exp:
     173             :       case Intrinsic::experimental_constrained_exp2:
     174             :       case Intrinsic::experimental_constrained_log:
     175             :       case Intrinsic::experimental_constrained_log10:
     176             :       case Intrinsic::experimental_constrained_log2:
     177             :       case Intrinsic::experimental_constrained_rint:
     178             :       case Intrinsic::experimental_constrained_nearbyint:
     179             :         return true;
     180             :       default: return false;
     181             :       }
     182             :     }
     183             :     static bool classof(const Value *V) {
     184             :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     185             :     }
     186             :   };
     187             : 
     188             :   /// This class represents atomic memcpy intrinsic
     189             :   /// TODO: Integrate this class into MemIntrinsic hierarchy; for now this is
     190             :   /// C&P of all methods from that hierarchy
     191             :   class ElementUnorderedAtomicMemCpyInst : public IntrinsicInst {
     192             :   private:
     193             :     enum { ARG_DEST = 0, ARG_SOURCE = 1, ARG_LENGTH = 2, ARG_ELEMENTSIZE = 3 };
     194             : 
     195             :   public:
     196             :     Value *getRawDest() const {
     197          16 :       return const_cast<Value *>(getArgOperand(ARG_DEST));
     198             :     }
     199             :     const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
     200             :     Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
     201             : 
     202             :     /// Return the arguments to the instruction.
     203             :     Value *getRawSource() const {
     204          16 :       return const_cast<Value *>(getArgOperand(ARG_SOURCE));
     205             :     }
     206             :     const Use &getRawSourceUse() const { return getArgOperandUse(ARG_SOURCE); }
     207             :     Use &getRawSourceUse() { return getArgOperandUse(ARG_SOURCE); }
     208             : 
     209             :     Value *getLength() const {
     210         144 :       return const_cast<Value *>(getArgOperand(ARG_LENGTH));
     211             :     }
     212             :     const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
     213             :     Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
     214             : 
     215             :     bool isVolatile() const { return false; }
     216             : 
     217             :     Value *getRawElementSizeInBytes() const {
     218         206 :       return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
     219             :     }
     220             : 
     221             :     ConstantInt *getElementSizeInBytesCst() const {
     222         104 :       return cast<ConstantInt>(getRawElementSizeInBytes());
     223             :     }
     224             : 
     225             :     uint32_t getElementSizeInBytes() const {
     226         104 :       return getElementSizeInBytesCst()->getZExtValue();
     227             :     }
     228             : 
     229             :     /// This is just like getRawDest, but it strips off any cast
     230             :     /// instructions that feed it, giving the original input.  The returned
     231             :     /// value is guaranteed to be a pointer.
     232             :     Value *getDest() const { return getRawDest()->stripPointerCasts(); }
     233             : 
     234             :     /// This is just like getRawSource, but it strips off any cast
     235             :     /// instructions that feed it, giving the original input.  The returned
     236             :     /// value is guaranteed to be a pointer.
     237             :     Value *getSource() const { return getRawSource()->stripPointerCasts(); }
     238             : 
     239             :     unsigned getDestAddressSpace() const {
     240             :       return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
     241             :     }
     242             : 
     243             :     unsigned getSourceAddressSpace() const {
     244             :       return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
     245             :     }
     246             : 
     247             :     /// Set the specified arguments of the instruction.
     248             :     void setDest(Value *Ptr) {
     249             :       assert(getRawDest()->getType() == Ptr->getType() &&
     250             :              "setDest called with pointer of wrong type!");
     251             :       setArgOperand(ARG_DEST, Ptr);
     252             :     }
     253             : 
     254             :     void setSource(Value *Ptr) {
     255             :       assert(getRawSource()->getType() == Ptr->getType() &&
     256             :              "setSource called with pointer of wrong type!");
     257             :       setArgOperand(ARG_SOURCE, Ptr);
     258             :     }
     259             : 
     260             :     void setLength(Value *L) {
     261             :       assert(getLength()->getType() == L->getType() &&
     262             :              "setLength called with value of wrong type!");
     263           4 :       setArgOperand(ARG_LENGTH, L);
     264             :     }
     265             : 
     266             :     void setElementSizeInBytes(Constant *V) {
     267             :       assert(V->getType() == Type::getInt8Ty(getContext()) &&
     268             :              "setElementSizeInBytes called with value of wrong type!");
     269             :       setArgOperand(ARG_ELEMENTSIZE, V);
     270             :     }
     271             : 
     272             :     static bool classof(const IntrinsicInst *I) {
     273      727731 :       return I->getIntrinsicID() == Intrinsic::memcpy_element_unordered_atomic;
     274             :     }
     275             :     static bool classof(const Value *V) {
     276             :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     277             :     }
     278             :   };
     279             : 
     280             :   class ElementUnorderedAtomicMemMoveInst : public IntrinsicInst {
     281             :   private:
     282             :     enum { ARG_DEST = 0, ARG_SOURCE = 1, ARG_LENGTH = 2, ARG_ELEMENTSIZE = 3 };
     283             : 
     284             :   public:
     285             :     Value *getRawDest() const {
     286          12 :       return const_cast<Value *>(getArgOperand(ARG_DEST));
     287             :     }
     288             :     const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
     289             :     Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
     290             : 
     291             :     /// Return the arguments to the instruction.
     292             :     Value *getRawSource() const {
     293          12 :       return const_cast<Value *>(getArgOperand(ARG_SOURCE));
     294             :     }
     295             :     const Use &getRawSourceUse() const { return getArgOperandUse(ARG_SOURCE); }
     296             :     Use &getRawSourceUse() { return getArgOperandUse(ARG_SOURCE); }
     297             : 
     298             :     Value *getLength() const {
     299         154 :       return const_cast<Value *>(getArgOperand(ARG_LENGTH));
     300             :     }
     301             :     const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
     302             :     Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
     303             : 
     304             :     bool isVolatile() const { return false; }
     305             : 
     306             :     Value *getRawElementSizeInBytes() const {
     307         256 :       return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
     308             :     }
     309             : 
     310             :     ConstantInt *getElementSizeInBytesCst() const {
     311         122 :       return cast<ConstantInt>(getRawElementSizeInBytes());
     312             :     }
     313             : 
     314             :     uint32_t getElementSizeInBytes() const {
     315         122 :       return getElementSizeInBytesCst()->getZExtValue();
     316             :     }
     317             : 
     318             :     /// This is just like getRawDest, but it strips off any cast
     319             :     /// instructions that feed it, giving the original input.  The returned
     320             :     /// value is guaranteed to be a pointer.
     321             :     Value *getDest() const { return getRawDest()->stripPointerCasts(); }
     322             : 
     323             :     /// This is just like getRawSource, but it strips off any cast
     324             :     /// instructions that feed it, giving the original input.  The returned
     325             :     /// value is guaranteed to be a pointer.
     326             :     Value *getSource() const { return getRawSource()->stripPointerCasts(); }
     327             : 
     328             :     unsigned getDestAddressSpace() const {
     329             :       return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
     330             :     }
     331             : 
     332             :     unsigned getSourceAddressSpace() const {
     333             :       return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
     334             :     }
     335             : 
     336             :     /// Set the specified arguments of the instruction.
     337             :     void setDest(Value *Ptr) {
     338             :       assert(getRawDest()->getType() == Ptr->getType() &&
     339             :              "setDest called with pointer of wrong type!");
     340             :       setArgOperand(ARG_DEST, Ptr);
     341             :     }
     342             : 
     343             :     void setSource(Value *Ptr) {
     344             :       assert(getRawSource()->getType() == Ptr->getType() &&
     345             :              "setSource called with pointer of wrong type!");
     346             :       setArgOperand(ARG_SOURCE, Ptr);
     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             :     void setElementSizeInBytes(Constant *V) {
     356             :       assert(V->getType() == Type::getInt8Ty(getContext()) &&
     357             :              "setElementSizeInBytes called with value of wrong type!");
     358             :       setArgOperand(ARG_ELEMENTSIZE, V);
     359             :     }
     360             : 
     361             :     static inline bool classof(const IntrinsicInst *I) {
     362             :       return I->getIntrinsicID() == Intrinsic::memmove_element_unordered_atomic;
     363             :     }
     364             :     static inline bool classof(const Value *V) {
     365             :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     366             :     }
     367             :   };
     368             : 
     369             :   /// This class represents atomic memset intrinsic
     370             :   /// TODO: Integrate this class into MemIntrinsic hierarchy; for now this is
     371             :   /// C&P of all methods from that hierarchy
     372             :   class ElementUnorderedAtomicMemSetInst : public IntrinsicInst {
     373             :   private:
     374             :     enum { ARG_DEST = 0, ARG_VALUE = 1, ARG_LENGTH = 2, ARG_ELEMENTSIZE = 3 };
     375             : 
     376             :   public:
     377             :     Value *getRawDest() const {
     378          12 :       return const_cast<Value *>(getArgOperand(ARG_DEST));
     379             :     }
     380             :     const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
     381             :     Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
     382             : 
     383          12 :     Value *getValue() const { return const_cast<Value*>(getArgOperand(ARG_VALUE)); }
     384             :     const Use &getValueUse() const { return getArgOperandUse(ARG_VALUE); }
     385             :     Use &getValueUse() { return getArgOperandUse(ARG_VALUE); }
     386             : 
     387             :     Value *getLength() const {
     388         110 :       return const_cast<Value *>(getArgOperand(ARG_LENGTH));
     389             :     }
     390             :     const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
     391             :     Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
     392             : 
     393             :     bool isVolatile() const { return false; }
     394             : 
     395             :     Value *getRawElementSizeInBytes() const {
     396         188 :       return const_cast<Value *>(getArgOperand(ARG_ELEMENTSIZE));
     397             :     }
     398             : 
     399             :     ConstantInt *getElementSizeInBytesCst() const {
     400          98 :       return cast<ConstantInt>(getRawElementSizeInBytes());
     401             :     }
     402             : 
     403             :     uint32_t getElementSizeInBytes() const {
     404          98 :       return getElementSizeInBytesCst()->getZExtValue();
     405             :     }
     406             : 
     407             :     /// This is just like getRawDest, but it strips off any cast
     408             :     /// instructions that feed it, giving the original input.  The returned
     409             :     /// value is guaranteed to be a pointer.
     410             :     Value *getDest() const { return getRawDest()->stripPointerCasts(); }
     411             : 
     412             :     unsigned getDestAddressSpace() const {
     413             :       return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
     414             :     }
     415             : 
     416             :     /// Set the specified arguments of the instruction.
     417             :     void setDest(Value *Ptr) {
     418             :       assert(getRawDest()->getType() == Ptr->getType() &&
     419             :              "setDest called with pointer of wrong type!");
     420             :       setArgOperand(ARG_DEST, Ptr);
     421             :     }
     422             : 
     423             :     void setValue(Value *Val) {
     424             :       assert(getValue()->getType() == Val->getType() &&
     425             :              "setValue called with value of wrong type!");
     426             :       setArgOperand(ARG_VALUE, Val);
     427             :     }
     428             : 
     429             :     void setLength(Value *L) {
     430             :       assert(getLength()->getType() == L->getType() &&
     431             :              "setLength called with value of wrong type!");
     432             :       setArgOperand(ARG_LENGTH, L);
     433             :     }
     434             : 
     435             :     void setElementSizeInBytes(Constant *V) {
     436             :       assert(V->getType() == Type::getInt8Ty(getContext()) &&
     437             :              "setElementSizeInBytes called with value of wrong type!");
     438             :       setArgOperand(ARG_ELEMENTSIZE, V);
     439             :     }
     440             : 
     441             :     static inline bool classof(const IntrinsicInst *I) {
     442             :       return I->getIntrinsicID() == Intrinsic::memset_element_unordered_atomic;
     443             :     }
     444             :     static inline bool classof(const Value *V) {
     445             :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     446             :     }
     447             :   };
     448             : 
     449             :   /// This is the common base class for memset/memcpy/memmove.
     450             :   class MemIntrinsic : public IntrinsicInst {
     451             :   public:
     452      482335 :     Value *getRawDest() const { return const_cast<Value*>(getArgOperand(0)); }
     453             :     const Use &getRawDestUse() const { return getArgOperandUse(0); }
     454        6132 :     Use &getRawDestUse() { return getArgOperandUse(0); }
     455             : 
     456      767206 :     Value *getLength() const { return const_cast<Value*>(getArgOperand(2)); }
     457             :     const Use &getLengthUse() const { return getArgOperandUse(2); }
     458             :     Use &getLengthUse() { return getArgOperandUse(2); }
     459             : 
     460             :     ConstantInt *getAlignmentCst() const {
     461      876000 :       return cast<ConstantInt>(const_cast<Value*>(getArgOperand(3)));
     462             :     }
     463             : 
     464             :     unsigned getAlignment() const {
     465      583988 :       return getAlignmentCst()->getZExtValue();
     466             :     }
     467             : 
     468             :     ConstantInt *getVolatileCst() const {
     469      759309 :       return cast<ConstantInt>(const_cast<Value*>(getArgOperand(4)));
     470             :     }
     471             : 
     472      253103 :     bool isVolatile() const {
     473      506206 :       return !getVolatileCst()->isZero();
     474             :     }
     475             : 
     476             :     unsigned getDestAddressSpace() const {
     477        2571 :       return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
     478             :     }
     479             : 
     480             :     /// This is just like getRawDest, but it strips off any cast
     481             :     /// instructions that feed it, giving the original input.  The returned
     482             :     /// value is guaranteed to be a pointer.
     483      442654 :     Value *getDest() const { return getRawDest()->stripPointerCasts(); }
     484             : 
     485             :     /// Set the specified arguments of the instruction.
     486             :     void setDest(Value *Ptr) {
     487             :       assert(getRawDest()->getType() == Ptr->getType() &&
     488             :              "setDest called with pointer of wrong type!");
     489          66 :       setArgOperand(0, Ptr);
     490             :     }
     491             : 
     492             :     void setLength(Value *L) {
     493             :       assert(getLength()->getType() == L->getType() &&
     494             :              "setLength called with value of wrong type!");
     495         274 :       setArgOperand(2, L);
     496             :     }
     497             : 
     498             :     void setAlignment(Constant* A) {
     499       25534 :       setArgOperand(3, A);
     500             :     }
     501             : 
     502             :     void setVolatile(Constant* V) {
     503             :       setArgOperand(4, V);
     504             :     }
     505             : 
     506             :     Type *getAlignmentType() const {
     507       25506 :       return getArgOperand(3)->getType();
     508             :     }
     509             : 
     510             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     511             :     static bool classof(const IntrinsicInst *I) {
     512     2647684 :       switch (I->getIntrinsicID()) {
     513             :       case Intrinsic::memcpy:
     514             :       case Intrinsic::memmove:
     515             :       case Intrinsic::memset:
     516             :         return true;
     517             :       default: return false;
     518             :       }
     519             :     }
     520     5492908 :     static bool classof(const Value *V) {
     521    14796912 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     522             :     }
     523             :   };
     524             : 
     525             :   /// This class wraps the llvm.memset intrinsic.
     526             :   class MemSetInst : public MemIntrinsic {
     527             :   public:
     528             :     /// Return the arguments to the instruction.
     529      391640 :     Value *getValue() const { return const_cast<Value*>(getArgOperand(1)); }
     530             :     const Use &getValueUse() const { return getArgOperandUse(1); }
     531             :     Use &getValueUse() { return getArgOperandUse(1); }
     532             : 
     533             :     void setValue(Value *Val) {
     534             :       assert(getValue()->getType() == Val->getType() &&
     535             :              "setValue called with value of wrong type!");
     536             :       setArgOperand(1, Val);
     537             :     }
     538             : 
     539             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     540             :     static bool classof(const IntrinsicInst *I) {
     541      418853 :       return I->getIntrinsicID() == Intrinsic::memset;
     542             :     }
     543             :     static bool classof(const Value *V) {
     544     3595157 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     545             :     }
     546             :   };
     547             : 
     548             :   /// This class wraps the llvm.memcpy/memmove intrinsics.
     549             :   class MemTransferInst : public MemIntrinsic {
     550             :   public:
     551             :     /// Return the arguments to the instruction.
     552       57300 :     Value *getRawSource() const { return const_cast<Value*>(getArgOperand(1)); }
     553             :     const Use &getRawSourceUse() const { return getArgOperandUse(1); }
     554             :     Use &getRawSourceUse() { return getArgOperandUse(1); }
     555             : 
     556             :     /// This is just like getRawSource, but it strips off any cast
     557             :     /// instructions that feed it, giving the original input.  The returned
     558             :     /// value is guaranteed to be a pointer.
     559       36250 :     Value *getSource() const { return getRawSource()->stripPointerCasts(); }
     560             : 
     561             :     unsigned getSourceAddressSpace() const {
     562        1056 :       return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
     563             :     }
     564             : 
     565             :     void setSource(Value *Ptr) {
     566             :       assert(getRawSource()->getType() == Ptr->getType() &&
     567             :              "setSource called with pointer of wrong type!");
     568          26 :       setArgOperand(1, Ptr);
     569             :     }
     570             : 
     571             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     572             :     static bool classof(const IntrinsicInst *I) {
     573      767832 :       return I->getIntrinsicID() == Intrinsic::memcpy ||
     574      375488 :              I->getIntrinsicID() == Intrinsic::memmove;
     575             :     }
     576             :     static bool classof(const Value *V) {
     577     1607813 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     578             :     }
     579             :   };
     580             : 
     581             :   /// This class wraps the llvm.memcpy intrinsic.
     582             :   class MemCpyInst : public MemTransferInst {
     583             :   public:
     584             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     585             :     static bool classof(const IntrinsicInst *I) {
     586     2545036 :       return I->getIntrinsicID() == Intrinsic::memcpy;
     587             :     }
     588             :     static bool classof(const Value *V) {
     589    13270786 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     590             :     }
     591             :   };
     592             : 
     593             :   /// This class wraps the llvm.memmove intrinsic.
     594             :   class MemMoveInst : public MemTransferInst {
     595             :   public:
     596             :     // Methods for support type inquiry through isa, cast, and dyn_cast:
     597             :     static bool classof(const IntrinsicInst *I) {
     598      270900 :       return I->getIntrinsicID() == Intrinsic::memmove;
     599             :     }
     600             :     static bool classof(const Value *V) {
     601     1928693 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     602             :     }
     603             :   };
     604             : 
     605             :   /// This represents the llvm.va_start intrinsic.
     606             :   class VAStartInst : public IntrinsicInst {
     607             :   public:
     608             :     static bool classof(const IntrinsicInst *I) {
     609             :       return I->getIntrinsicID() == Intrinsic::vastart;
     610             :     }
     611             :     static bool classof(const Value *V) {
     612             :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     613             :     }
     614             : 
     615             :     Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
     616             :   };
     617             : 
     618             :   /// This represents the llvm.va_end intrinsic.
     619             :   class VAEndInst : public IntrinsicInst {
     620             :   public:
     621             :     static bool classof(const IntrinsicInst *I) {
     622             :       return I->getIntrinsicID() == Intrinsic::vaend;
     623             :     }
     624             :     static bool classof(const Value *V) {
     625             :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     626             :     }
     627             : 
     628             :     Value *getArgList() const { return const_cast<Value*>(getArgOperand(0)); }
     629             :   };
     630             : 
     631             :   /// This represents the llvm.va_copy intrinsic.
     632             :   class VACopyInst : public IntrinsicInst {
     633             :   public:
     634             :     static bool classof(const IntrinsicInst *I) {
     635             :       return I->getIntrinsicID() == Intrinsic::vacopy;
     636             :     }
     637             :     static bool classof(const Value *V) {
     638             :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     639             :     }
     640             : 
     641             :     Value *getDest() const { return const_cast<Value*>(getArgOperand(0)); }
     642             :     Value *getSrc() const { return const_cast<Value*>(getArgOperand(1)); }
     643             :   };
     644             : 
     645             :   /// This represents the llvm.instrprof_increment intrinsic.
     646             :   class InstrProfIncrementInst : public IntrinsicInst {
     647             :   public:
     648             :     static bool classof(const IntrinsicInst *I) {
     649        1124 :       return I->getIntrinsicID() == Intrinsic::instrprof_increment;
     650             :     }
     651             :     static bool classof(const Value *V) {
     652       10289 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     653             :     }
     654             : 
     655             :     GlobalVariable *getName() const {
     656        6504 :       return cast<GlobalVariable>(
     657        2168 :           const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
     658             :     }
     659             : 
     660             :     ConstantInt *getHash() const {
     661        1032 :       return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
     662             :     }
     663             : 
     664             :     ConstantInt *getNumCounters() const {
     665        1005 :       return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2)));
     666             :     }
     667             : 
     668             :     ConstantInt *getIndex() const {
     669        2265 :       return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
     670             :     }
     671             : 
     672             :     Value *getStep() const;
     673             :   };
     674             : 
     675             :   class InstrProfIncrementInstStep : public InstrProfIncrementInst {
     676             :   public:
     677             :     static bool classof(const IntrinsicInst *I) {
     678        1544 :       return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
     679             :     }
     680             :     static bool classof(const Value *V) {
     681        7746 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     682             :     }
     683             :   };
     684             : 
     685             :   /// This represents the llvm.instrprof_value_profile intrinsic.
     686             :   class InstrProfValueProfileInst : public IntrinsicInst {
     687             :   public:
     688             :     static bool classof(const IntrinsicInst *I) {
     689         823 :       return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
     690             :     }
     691             :     static bool classof(const Value *V) {
     692       12472 :       return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
     693             :     }
     694             : 
     695             :     GlobalVariable *getName() const {
     696         108 :       return cast<GlobalVariable>(
     697          36 :           const_cast<Value *>(getArgOperand(0))->stripPointerCasts());
     698             :     }
     699             : 
     700             :     ConstantInt *getHash() const {
     701             :       return cast<ConstantInt>(const_cast<Value *>(getArgOperand(1)));
     702             :     }
     703             : 
     704             :     Value *getTargetValue() const {
     705          54 :       return cast<Value>(const_cast<Value *>(getArgOperand(2)));
     706             :     }
     707             : 
     708             :     ConstantInt *getValueKind() const {
     709         162 :       return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3)));
     710             :     }
     711             : 
     712             :     // Returns the value site index.
     713             :     ConstantInt *getIndex() const {
     714         108 :       return cast<ConstantInt>(const_cast<Value *>(getArgOperand(4)));
     715             :     }
     716             :   };
     717             : 
     718             : } // end namespace llvm
     719             : 
     720             : #endif // LLVM_IR_INTRINSICINST_H

Generated by: LCOV version 1.13