LCOV - code coverage report
Current view: top level - include/llvm/IR - Instruction.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 49 49 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/Instruction.h - Instruction class definition -------*- 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 contains the declaration of the Instruction class, which is the
      11             : // base class for all of the LLVM instructions.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #ifndef LLVM_IR_INSTRUCTION_H
      16             : #define LLVM_IR_INSTRUCTION_H
      17             : 
      18             : #include "llvm/ADT/ArrayRef.h"
      19             : #include "llvm/ADT/None.h"
      20             : #include "llvm/ADT/StringRef.h"
      21             : #include "llvm/ADT/ilist_node.h"
      22             : #include "llvm/IR/DebugLoc.h"
      23             : #include "llvm/IR/SymbolTableListTraits.h"
      24             : #include "llvm/IR/User.h"
      25             : #include "llvm/IR/Value.h"
      26             : #include "llvm/Support/Casting.h"
      27             : #include <algorithm>
      28             : #include <cassert>
      29             : #include <cstdint>
      30             : #include <utility>
      31             : 
      32             : namespace llvm {
      33             : 
      34             : class BasicBlock;
      35             : class FastMathFlags;
      36             : class MDNode;
      37             : struct AAMDNodes;
      38             : 
      39             : template <> struct ilist_alloc_traits<Instruction> {
      40             :   static inline void deleteNode(Instruction *V);
      41             : };
      42             : 
      43             : class Instruction : public User,
      44             :                     public ilist_node_with_parent<Instruction, BasicBlock> {
      45             :   BasicBlock *Parent;
      46             :   DebugLoc DbgLoc;                         // 'dbg' Metadata cache.
      47             : 
      48             :   enum {
      49             :     /// This is a bit stored in the SubClassData field which indicates whether
      50             :     /// this instruction has metadata attached to it or not.
      51             :     HasMetadataBit = 1 << 15
      52             :   };
      53             : 
      54             : protected:
      55             :   ~Instruction(); // Use deleteValue() to delete a generic Instruction.
      56             : 
      57             : public:
      58             :   Instruction(const Instruction &) = delete;
      59             :   Instruction &operator=(const Instruction &) = delete;
      60             : 
      61             :   /// Specialize the methods defined in Value, as we know that an instruction
      62             :   /// can only be used by other instructions.
      63    26883428 :   Instruction       *user_back()       { return cast<Instruction>(*user_begin());}
      64       12648 :   const Instruction *user_back() const { return cast<Instruction>(*user_begin());}
      65             : 
      66             :   inline const BasicBlock *getParent() const { return Parent; }
      67             :   inline       BasicBlock *getParent()       { return Parent; }
      68             : 
      69             :   /// Return the module owning the function this instruction belongs to
      70             :   /// or nullptr it the function does not have a module.
      71             :   ///
      72             :   /// Note: this is undefined behavior if the instruction does not have a
      73             :   /// parent, or the parent basic block does not have a parent function.
      74             :   const Module *getModule() const;
      75             :   Module *getModule() {
      76             :     return const_cast<Module *>(
      77    11608676 :                            static_cast<const Instruction *>(this)->getModule());
      78             :   }
      79             : 
      80             :   /// Return the function this instruction belongs to.
      81             :   ///
      82             :   /// Note: it is undefined behavior to call this on an instruction not
      83             :   /// currently inserted into a function.
      84             :   const Function *getFunction() const;
      85             :   Function *getFunction() {
      86             :     return const_cast<Function *>(
      87     3085669 :                          static_cast<const Instruction *>(this)->getFunction());
      88             :   }
      89             : 
      90             :   /// This method unlinks 'this' from the containing basic block, but does not
      91             :   /// delete it.
      92             :   void removeFromParent();
      93             : 
      94             :   /// This method unlinks 'this' from the containing basic block and deletes it.
      95             :   ///
      96             :   /// \returns an iterator pointing to the element after the erased one
      97             :   SymbolTableList<Instruction>::iterator eraseFromParent();
      98             : 
      99             :   /// Insert an unlinked instruction into a basic block immediately before
     100             :   /// the specified instruction.
     101             :   void insertBefore(Instruction *InsertPos);
     102             : 
     103             :   /// Insert an unlinked instruction into a basic block immediately after the
     104             :   /// specified instruction.
     105             :   void insertAfter(Instruction *InsertPos);
     106             : 
     107             :   /// Unlink this instruction from its current basic block and insert it into
     108             :   /// the basic block that MovePos lives in, right before MovePos.
     109             :   void moveBefore(Instruction *MovePos);
     110             : 
     111             :   /// Unlink this instruction and insert into BB before I.
     112             :   ///
     113             :   /// \pre I is a valid iterator into BB.
     114             :   void moveBefore(BasicBlock &BB, SymbolTableList<Instruction>::iterator I);
     115             : 
     116             :   /// Unlink this instruction from its current basic block and insert it into
     117             :   /// the basic block that MovePos lives in, right after MovePos.
     118             :   void moveAfter(Instruction *MovePos);
     119             : 
     120             :   //===--------------------------------------------------------------------===//
     121             :   // Subclass classification.
     122             :   //===--------------------------------------------------------------------===//
     123             : 
     124             :   /// Returns a member of one of the enums like Instruction::Add.
     125  2446033639 :   unsigned getOpcode() const { return getValueID() - InstructionVal; }
     126             : 
     127     1372278 :   const char *getOpcodeName() const { return getOpcodeName(getOpcode()); }
     128   336977288 :   bool isTerminator() const { return isTerminator(getOpcode()); }
     129    89819199 :   bool isBinaryOp() const { return isBinaryOp(getOpcode()); }
     130         624 :   bool isShift() { return isShift(getOpcode()); }
     131    54458838 :   bool isCast() const { return isCast(getOpcode()); }
     132     2621996 :   bool isFuncletPad() const { return isFuncletPad(getOpcode()); }
     133             : 
     134             :   static const char* getOpcodeName(unsigned OpCode);
     135             : 
     136             :   static inline bool isTerminator(unsigned OpCode) {
     137   168488644 :     return OpCode >= TermOpsBegin && OpCode < TermOpsEnd;
     138             :   }
     139             : 
     140             :   static inline bool isBinaryOp(unsigned Opcode) {
     141    58634125 :     return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd;
     142             :   }
     143             : 
     144             :   /// Determine if the Opcode is one of the shift instructions.
     145             :   static inline bool isShift(unsigned Opcode) {
     146         333 :     return Opcode >= Shl && Opcode <= AShr;
     147             :   }
     148             : 
     149             :   /// Return true if this is a logical shift left or a logical shift right.
     150             :   inline bool isLogicalShift() const {
     151       16041 :     return getOpcode() == Shl || getOpcode() == LShr;
     152             :   }
     153             : 
     154             :   /// Return true if this is an arithmetic shift right.
     155             :   inline bool isArithmeticShift() const {
     156          15 :     return getOpcode() == AShr;
     157             :   }
     158             : 
     159             :   /// Determine if the Opcode is and/or/xor.
     160             :   static inline bool isBitwiseLogicOp(unsigned Opcode) {
     161        2804 :     return Opcode == And || Opcode == Or || Opcode == Xor;
     162             :   }
     163             : 
     164             :   /// Return true if this is and/or/xor.
     165             :   inline bool isBitwiseLogicOp() const {
     166        5298 :     return isBitwiseLogicOp(getOpcode());
     167             :   }
     168             : 
     169             :   /// Determine if the OpCode is one of the CastInst instructions.
     170             :   static inline bool isCast(unsigned OpCode) {
     171    42311737 :     return OpCode >= CastOpsBegin && OpCode < CastOpsEnd;
     172             :   }
     173             : 
     174             :   /// Determine if the OpCode is one of the FuncletPadInst instructions.
     175             :   static inline bool isFuncletPad(unsigned OpCode) {
     176     1310895 :     return OpCode >= FuncletPadOpsBegin && OpCode < FuncletPadOpsEnd;
     177             :   }
     178             : 
     179             :   //===--------------------------------------------------------------------===//
     180             :   // Metadata manipulation.
     181             :   //===--------------------------------------------------------------------===//
     182             : 
     183             :   /// Return true if this instruction has any metadata attached to it.
     184   380129254 :   bool hasMetadata() const { return DbgLoc || hasMetadataHashEntry(); }
     185             : 
     186             :   /// Return true if this instruction has metadata attached to it other than a
     187             :   /// debug location.
     188             :   bool hasMetadataOtherThanDebugLoc() const {
     189     6843902 :     return hasMetadataHashEntry();
     190             :   }
     191             : 
     192             :   /// Get the metadata of given kind attached to this Instruction.
     193             :   /// If the metadata is not found then return null.
     194             :   MDNode *getMetadata(unsigned KindID) const {
     195             :     if (!hasMetadata()) return nullptr;
     196    83614825 :     return getMetadataImpl(KindID);
     197             :   }
     198             : 
     199             :   /// Get the metadata of given kind attached to this Instruction.
     200             :   /// If the metadata is not found then return null.
     201             :   MDNode *getMetadata(StringRef Kind) const {
     202             :     if (!hasMetadata()) return nullptr;
     203        7537 :     return getMetadataImpl(Kind);
     204             :   }
     205             : 
     206             :   /// Get all metadata attached to this Instruction. The first element of each
     207             :   /// pair returned is the KindID, the second element is the metadata value.
     208             :   /// This list is returned sorted by the KindID.
     209             :   void
     210             :   getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
     211             :     if (hasMetadata())
     212     1444926 :       getAllMetadataImpl(MDs);
     213             :   }
     214             : 
     215             :   /// This does the same thing as getAllMetadata, except that it filters out the
     216             :   /// debug location.
     217             :   void getAllMetadataOtherThanDebugLoc(
     218             :       SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
     219     6778159 :     if (hasMetadataOtherThanDebugLoc())
     220      497198 :       getAllMetadataOtherThanDebugLocImpl(MDs);
     221             :   }
     222             : 
     223             :   /// Fills the AAMDNodes structure with AA metadata from this instruction.
     224             :   /// When Merge is true, the existing AA metadata is merged with that from this
     225             :   /// instruction providing the most-general result.
     226             :   void getAAMetadata(AAMDNodes &N, bool Merge = false) const;
     227             : 
     228             :   /// Set the metadata of the specified kind to the specified node. This updates
     229             :   /// or replaces metadata if already present, or removes it if Node is null.
     230             :   void setMetadata(unsigned KindID, MDNode *Node);
     231             :   void setMetadata(StringRef Kind, MDNode *Node);
     232             : 
     233             :   /// Copy metadata from \p SrcInst to this instruction. \p WL, if not empty,
     234             :   /// specifies the list of meta data that needs to be copied. If \p WL is
     235             :   /// empty, all meta data will be copied.
     236             :   void copyMetadata(const Instruction &SrcInst,
     237             :                     ArrayRef<unsigned> WL = ArrayRef<unsigned>());
     238             : 
     239             :   /// If the instruction has "branch_weights" MD_prof metadata and the MDNode
     240             :   /// has three operands (including name string), swap the order of the
     241             :   /// metadata.
     242             :   void swapProfMetadata();
     243             : 
     244             :   /// Drop all unknown metadata except for debug locations.
     245             :   /// @{
     246             :   /// Passes are required to drop metadata they don't understand. This is a
     247             :   /// convenience method for passes to do so.
     248             :   void dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs);
     249             :   void dropUnknownNonDebugMetadata() {
     250        2122 :     return dropUnknownNonDebugMetadata(None);
     251             :   }
     252             :   void dropUnknownNonDebugMetadata(unsigned ID1) {
     253             :     return dropUnknownNonDebugMetadata(makeArrayRef(ID1));
     254             :   }
     255             :   void dropUnknownNonDebugMetadata(unsigned ID1, unsigned ID2) {
     256             :     unsigned IDs[] = {ID1, ID2};
     257             :     return dropUnknownNonDebugMetadata(IDs);
     258             :   }
     259             :   /// @}
     260             : 
     261             :   /// Sets the metadata on this instruction from the AAMDNodes structure.
     262             :   void setAAMetadata(const AAMDNodes &N);
     263             : 
     264             :   /// Retrieve the raw weight values of a conditional branch or select.
     265             :   /// Returns true on success with profile weights filled in.
     266             :   /// Returns false if no metadata or invalid metadata was found.
     267             :   bool extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) const;
     268             : 
     269             :   /// Retrieve total raw weight values of a branch.
     270             :   /// Returns true on success with profile total weights filled in.
     271             :   /// Returns false if no metadata was found.
     272             :   bool extractProfTotalWeight(uint64_t &TotalVal) const;
     273             : 
     274             :   /// Updates branch_weights metadata by scaling it by \p S / \p T.
     275             :   void updateProfWeight(uint64_t S, uint64_t T);
     276             : 
     277             :   /// Sets the branch_weights metadata to \p W for CallInst.
     278             :   void setProfWeight(uint64_t W);
     279             : 
     280             :   /// Set the debug location information for this instruction.
     281     8847544 :   void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
     282             : 
     283             :   /// Return the debug location for this node as a DebugLoc.
     284     3454322 :   const DebugLoc &getDebugLoc() const { return DbgLoc; }
     285             : 
     286             :   /// Set or clear the nsw flag on this instruction, which must be an operator
     287             :   /// which supports this flag. See LangRef.html for the meaning of this flag.
     288             :   void setHasNoUnsignedWrap(bool b = true);
     289             : 
     290             :   /// Set or clear the nsw flag on this instruction, which must be an operator
     291             :   /// which supports this flag. See LangRef.html for the meaning of this flag.
     292             :   void setHasNoSignedWrap(bool b = true);
     293             : 
     294             :   /// Set or clear the exact flag on this instruction, which must be an operator
     295             :   /// which supports this flag. See LangRef.html for the meaning of this flag.
     296             :   void setIsExact(bool b = true);
     297             : 
     298             :   /// Determine whether the no unsigned wrap flag is set.
     299             :   bool hasNoUnsignedWrap() const;
     300             : 
     301             :   /// Determine whether the no signed wrap flag is set.
     302             :   bool hasNoSignedWrap() const;
     303             : 
     304             :   /// Drops flags that may cause this instruction to evaluate to poison despite
     305             :   /// having non-poison inputs.
     306             :   void dropPoisonGeneratingFlags();
     307             : 
     308             :   /// Determine whether the exact flag is set.
     309             :   bool isExact() const;
     310             : 
     311             :   /// Set or clear the unsafe-algebra flag on this instruction, which must be an
     312             :   /// operator which supports this flag. See LangRef.html for the meaning of
     313             :   /// this flag.
     314             :   void setHasUnsafeAlgebra(bool B);
     315             : 
     316             :   /// Set or clear the no-nans flag on this instruction, which must be an
     317             :   /// operator which supports this flag. See LangRef.html for the meaning of
     318             :   /// this flag.
     319             :   void setHasNoNaNs(bool B);
     320             : 
     321             :   /// Set or clear the no-infs flag on this instruction, which must be an
     322             :   /// operator which supports this flag. See LangRef.html for the meaning of
     323             :   /// this flag.
     324             :   void setHasNoInfs(bool B);
     325             : 
     326             :   /// Set or clear the no-signed-zeros flag on this instruction, which must be
     327             :   /// an operator which supports this flag. See LangRef.html for the meaning of
     328             :   /// this flag.
     329             :   void setHasNoSignedZeros(bool B);
     330             : 
     331             :   /// Set or clear the allow-reciprocal flag on this instruction, which must be
     332             :   /// an operator which supports this flag. See LangRef.html for the meaning of
     333             :   /// this flag.
     334             :   void setHasAllowReciprocal(bool B);
     335             : 
     336             :   /// Convenience function for setting multiple fast-math flags on this
     337             :   /// instruction, which must be an operator which supports these flags. See
     338             :   /// LangRef.html for the meaning of these flags.
     339             :   void setFastMathFlags(FastMathFlags FMF);
     340             : 
     341             :   /// Convenience function for transferring all fast-math flag values to this
     342             :   /// instruction, which must be an operator which supports these flags. See
     343             :   /// LangRef.html for the meaning of these flags.
     344             :   void copyFastMathFlags(FastMathFlags FMF);
     345             : 
     346             :   /// Determine whether the unsafe-algebra flag is set.
     347             :   bool hasUnsafeAlgebra() const;
     348             : 
     349             :   /// Determine whether the no-NaNs flag is set.
     350             :   bool hasNoNaNs() const;
     351             : 
     352             :   /// Determine whether the no-infs flag is set.
     353             :   bool hasNoInfs() const;
     354             : 
     355             :   /// Determine whether the no-signed-zeros flag is set.
     356             :   bool hasNoSignedZeros() const;
     357             : 
     358             :   /// Determine whether the allow-reciprocal flag is set.
     359             :   bool hasAllowReciprocal() const;
     360             : 
     361             :   /// Determine whether the allow-contract flag is set.
     362             :   bool hasAllowContract() const;
     363             : 
     364             :   /// Convenience function for getting all the fast-math flags, which must be an
     365             :   /// operator which supports these flags. See LangRef.html for the meaning of
     366             :   /// these flags.
     367             :   FastMathFlags getFastMathFlags() const;
     368             : 
     369             :   /// Copy I's fast-math flags
     370             :   void copyFastMathFlags(const Instruction *I);
     371             : 
     372             :   /// Convenience method to copy supported exact, fast-math, and (optionally)
     373             :   /// wrapping flags from V to this instruction.
     374             :   void copyIRFlags(const Value *V, bool IncludeWrapFlags = true);
     375             : 
     376             :   /// Logical 'and' of any supported wrapping, exact, and fast-math flags of
     377             :   /// V and this instruction.
     378             :   void andIRFlags(const Value *V);
     379             : 
     380             : private:
     381             :   /// Return true if we have an entry in the on-the-side metadata hash.
     382             :   bool hasMetadataHashEntry() const {
     383   168103360 :     return (getSubclassDataFromValue() & HasMetadataBit) != 0;
     384             :   }
     385             : 
     386             :   // These are all implemented in Metadata.cpp.
     387             :   MDNode *getMetadataImpl(unsigned KindID) const;
     388             :   MDNode *getMetadataImpl(StringRef Kind) const;
     389             :   void
     390             :   getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const;
     391             :   void getAllMetadataOtherThanDebugLocImpl(
     392             :       SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const;
     393             :   /// Clear all hashtable-based metadata from this instruction.
     394             :   void clearMetadataHashEntries();
     395             : 
     396             : public:
     397             :   //===--------------------------------------------------------------------===//
     398             :   // Predicates and helper methods.
     399             :   //===--------------------------------------------------------------------===//
     400             : 
     401             :   /// Return true if the instruction is associative:
     402             :   ///
     403             :   ///   Associative operators satisfy:  x op (y op z) === (x op y) op z
     404             :   ///
     405             :   /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
     406             :   ///
     407             :   bool isAssociative() const LLVM_READONLY;
     408             :   static bool isAssociative(unsigned Opcode) {
     409    13781692 :     return Opcode == And || Opcode == Or || Opcode == Xor ||
     410    13781692 :            Opcode == Add || Opcode == Mul;
     411             :   }
     412             : 
     413             :   /// Return true if the instruction is commutative:
     414             :   ///
     415             :   ///   Commutative operators satisfy: (x op y) === (y op x)
     416             :   ///
     417             :   /// In LLVM, these are the commutative operators, plus SetEQ and SetNE, when
     418             :   /// applied to any type.
     419             :   ///
     420    10188586 :   bool isCommutative() const { return isCommutative(getOpcode()); }
     421             :   static bool isCommutative(unsigned Opcode) {
     422             :     switch (Opcode) {
     423             :     case Add: case FAdd:
     424             :     case Mul: case FMul:
     425             :     case And: case Or: case Xor:
     426             :       return true;
     427         220 :     default:
     428             :       return false;
     429             :   }
     430             :   }
     431             : 
     432             :   /// Return true if the instruction is idempotent:
     433             :   ///
     434             :   ///   Idempotent operators satisfy:  x op x === x
     435             :   ///
     436             :   /// In LLVM, the And and Or operators are idempotent.
     437             :   ///
     438             :   bool isIdempotent() const { return isIdempotent(getOpcode()); }
     439             :   static bool isIdempotent(unsigned Opcode) {
     440         402 :     return Opcode == And || Opcode == Or;
     441             :   }
     442             : 
     443             :   /// Return true if the instruction is nilpotent:
     444             :   ///
     445             :   ///   Nilpotent operators satisfy:  x op x === Id,
     446             :   ///
     447             :   ///   where Id is the identity for the operator, i.e. a constant such that
     448             :   ///     x op Id === x and Id op x === x for all x.
     449             :   ///
     450             :   /// In LLVM, the Xor operator is nilpotent.
     451             :   ///
     452             :   bool isNilpotent() const { return isNilpotent(getOpcode()); }
     453             :   static bool isNilpotent(unsigned Opcode) {
     454             :     return Opcode == Xor;
     455             :   }
     456             : 
     457             :   /// Return true if this instruction may modify memory.
     458             :   bool mayWriteToMemory() const;
     459             : 
     460             :   /// Return true if this instruction may read memory.
     461             :   bool mayReadFromMemory() const;
     462             : 
     463             :   /// Return true if this instruction may read or write memory.
     464     3695026 :   bool mayReadOrWriteMemory() const {
     465     3695026 :     return mayReadFromMemory() || mayWriteToMemory();
     466             :   }
     467             : 
     468             :   /// Return true if this instruction has an AtomicOrdering of unordered or
     469             :   /// higher.
     470             :   bool isAtomic() const;
     471             : 
     472             :   /// Return true if this atomic instruction loads from memory.
     473             :   bool hasAtomicLoad() const;
     474             : 
     475             :   /// Return true if this atomic instruction stores to memory.
     476             :   bool hasAtomicStore() const;
     477             : 
     478             :   /// Return true if this instruction may throw an exception.
     479             :   bool mayThrow() const;
     480             : 
     481             :   /// Return true if this instruction behaves like a memory fence: it can load
     482             :   /// or store to memory location without being given a memory location.
     483             :   bool isFenceLike() const {
     484      100370 :     switch (getOpcode()) {
     485             :     default:
     486             :       return false;
     487             :     // This list should be kept in sync with the list in mayWriteToMemory for
     488             :     // all opcodes which don't have a memory location.
     489             :     case Instruction::Fence:
     490             :     case Instruction::CatchPad:
     491             :     case Instruction::CatchRet:
     492             :     case Instruction::Call:
     493             :     case Instruction::Invoke:
     494             :       return true;
     495             :     }
     496             :   }
     497             : 
     498             :   /// Return true if the instruction may have side effects.
     499             :   ///
     500             :   /// Note that this does not consider malloc and alloca to have side
     501             :   /// effects because the newly allocated memory is completely invisible to
     502             :   /// instructions which don't use the returned value.  For cases where this
     503             :   /// matters, isSafeToSpeculativelyExecute may be more appropriate.
     504    23087536 :   bool mayHaveSideEffects() const { return mayWriteToMemory() || mayThrow(); }
     505             : 
     506             :   /// Return true if the instruction is a variety of EH-block.
     507             :   bool isEHPad() const {
     508    23821639 :     switch (getOpcode()) {
     509             :     case Instruction::CatchSwitch:
     510             :     case Instruction::CatchPad:
     511             :     case Instruction::CleanupPad:
     512             :     case Instruction::LandingPad:
     513             :       return true;
     514      981723 :     default:
     515             :       return false;
     516             :     }
     517             :   }
     518             : 
     519             :   /// Create a copy of 'this' instruction that is identical in all ways except
     520             :   /// the following:
     521             :   ///   * The instruction has no parent
     522             :   ///   * The instruction has no name
     523             :   ///
     524             :   Instruction *clone() const;
     525             : 
     526             :   /// Return true if the specified instruction is exactly identical to the
     527             :   /// current one. This means that all operands match and any extra information
     528             :   /// (e.g. load is volatile) agree.
     529             :   bool isIdenticalTo(const Instruction *I) const;
     530             : 
     531             :   /// This is like isIdenticalTo, except that it ignores the
     532             :   /// SubclassOptionalData flags, which may specify conditions under which the
     533             :   /// instruction's result is undefined.
     534             :   bool isIdenticalToWhenDefined(const Instruction *I) const;
     535             : 
     536             :   /// When checking for operation equivalence (using isSameOperationAs) it is
     537             :   /// sometimes useful to ignore certain attributes.
     538             :   enum OperationEquivalenceFlags {
     539             :     /// Check for equivalence ignoring load/store alignment.
     540             :     CompareIgnoringAlignment = 1<<0,
     541             :     /// Check for equivalence treating a type and a vector of that type
     542             :     /// as equivalent.
     543             :     CompareUsingScalarTypes = 1<<1
     544             :   };
     545             : 
     546             :   /// This function determines if the specified instruction executes the same
     547             :   /// operation as the current one. This means that the opcodes, type, operand
     548             :   /// types and any other factors affecting the operation must be the same. This
     549             :   /// is similar to isIdenticalTo except the operands themselves don't have to
     550             :   /// be identical.
     551             :   /// @returns true if the specified instruction is the same operation as
     552             :   /// the current one.
     553             :   /// @brief Determine if one instruction is the same operation as another.
     554             :   bool isSameOperationAs(const Instruction *I, unsigned flags = 0) const;
     555             : 
     556             :   /// Return true if there are any uses of this instruction in blocks other than
     557             :   /// the specified block. Note that PHI nodes are considered to evaluate their
     558             :   /// operands in the corresponding predecessor block.
     559             :   bool isUsedOutsideOfBlock(const BasicBlock *BB) const;
     560             : 
     561             : 
     562             :   /// Methods for support type inquiry through isa, cast, and dyn_cast:
     563             :   static bool classof(const Value *V) {
     564   193582481 :     return V->getValueID() >= Value::InstructionVal;
     565             :   }
     566             : 
     567             :   //----------------------------------------------------------------------
     568             :   // Exported enumerations.
     569             :   //
     570             :   enum TermOps {       // These terminate basic blocks
     571             : #define  FIRST_TERM_INST(N)             TermOpsBegin = N,
     572             : #define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N,
     573             : #define   LAST_TERM_INST(N)             TermOpsEnd = N+1
     574             : #include "llvm/IR/Instruction.def"
     575             :   };
     576             : 
     577             :   enum BinaryOps {
     578             : #define  FIRST_BINARY_INST(N)             BinaryOpsBegin = N,
     579             : #define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N,
     580             : #define   LAST_BINARY_INST(N)             BinaryOpsEnd = N+1
     581             : #include "llvm/IR/Instruction.def"
     582             :   };
     583             : 
     584             :   enum MemoryOps {
     585             : #define  FIRST_MEMORY_INST(N)             MemoryOpsBegin = N,
     586             : #define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N,
     587             : #define   LAST_MEMORY_INST(N)             MemoryOpsEnd = N+1
     588             : #include "llvm/IR/Instruction.def"
     589             :   };
     590             : 
     591             :   enum CastOps {
     592             : #define  FIRST_CAST_INST(N)             CastOpsBegin = N,
     593             : #define HANDLE_CAST_INST(N, OPC, CLASS) OPC = N,
     594             : #define   LAST_CAST_INST(N)             CastOpsEnd = N+1
     595             : #include "llvm/IR/Instruction.def"
     596             :   };
     597             : 
     598             :   enum FuncletPadOps {
     599             : #define  FIRST_FUNCLETPAD_INST(N)             FuncletPadOpsBegin = N,
     600             : #define HANDLE_FUNCLETPAD_INST(N, OPC, CLASS) OPC = N,
     601             : #define   LAST_FUNCLETPAD_INST(N)             FuncletPadOpsEnd = N+1
     602             : #include "llvm/IR/Instruction.def"
     603             :   };
     604             : 
     605             :   enum OtherOps {
     606             : #define  FIRST_OTHER_INST(N)             OtherOpsBegin = N,
     607             : #define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N,
     608             : #define   LAST_OTHER_INST(N)             OtherOpsEnd = N+1
     609             : #include "llvm/IR/Instruction.def"
     610             :   };
     611             : 
     612             : private:
     613             :   friend class SymbolTableListTraits<Instruction>;
     614             : 
     615             :   // Shadow Value::setValueSubclassData with a private forwarding method so that
     616             :   // subclasses cannot accidentally use it.
     617             :   void setValueSubclassData(unsigned short D) {
     618    24379899 :     Value::setValueSubclassData(D);
     619             :   }
     620             : 
     621             :   unsigned short getSubclassDataFromValue() const {
     622   375049537 :     return Value::getSubclassDataFromValue();
     623             :   }
     624             : 
     625             :   void setHasMetadataHashEntry(bool V) {
     626     1279174 :     setValueSubclassData((getSubclassDataFromValue() & ~HasMetadataBit) |
     627             :                          (V ? HasMetadataBit : 0));
     628             :   }
     629             : 
     630             :   void setParent(BasicBlock *P);
     631             : 
     632             : protected:
     633             :   // Instruction subclasses can stick up to 15 bits of stuff into the
     634             :   // SubclassData field of instruction with these members.
     635             : 
     636             :   // Verify that only the low 15 bits are used.
     637             :   void setInstructionSubclassData(unsigned short D) {
     638             :     assert((D & HasMetadataBit) == 0 && "Out of range value put into field");
     639    23283424 :     setValueSubclassData((getSubclassDataFromValue() & HasMetadataBit) | D);
     640             :   }
     641             : 
     642             :   unsigned getSubclassDataFromInstruction() const {
     643   194664878 :     return getSubclassDataFromValue() & ~HasMetadataBit;
     644             :   }
     645             : 
     646             :   Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
     647             :               Instruction *InsertBefore = nullptr);
     648             :   Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
     649             :               BasicBlock *InsertAtEnd);
     650             : 
     651             : private:
     652             :   /// Create a copy of this instruction.
     653             :   Instruction *cloneImpl() const;
     654             : };
     655             : 
     656             : inline void ilist_alloc_traits<Instruction>::deleteNode(Instruction *V) {
     657     5282695 :   V->deleteValue();
     658             : }
     659             : 
     660             : } // end namespace llvm
     661             : 
     662             : #endif // LLVM_IR_INSTRUCTION_H

Generated by: LCOV version 1.13