14#ifndef LLVM_IR_INSTRUCTION_H 
   15#define LLVM_IR_INSTRUCTION_H 
   57                           "BasicBlock::iterator")
 
   62  bool isValid()
 const { 
return InsertAt.isValid(); }
 
 
   68                                                  ilist_iterator_bits<true>,
 
   69                                                  ilist_parent<BasicBlock>> {
 
   79  mutable unsigned Order = 0;
 
  102      bool InsertAtHead = 
false);
 
  112  LLVM_ABI std::optional<simple_ilist<DbgRecord>::iterator>
 
  113  getDbgReinsertionPosition();
 
  116  LLVM_ABI bool hasDbgRecords() 
const;
 
  132  LLVM_ABI void handleMarkerRemoval();
 
  144  template <
unsigned Offset>
 
  149  template <
unsigned Offset>
 
  152  template <
unsigned Offset>
 
  181    return const_cast<Module *
>(
 
  182                           static_cast<const Instruction *
>(
this)->getModule());
 
 
  192                         static_cast<const Instruction *
>(
this)->getFunction());
 
 
  207  LLVM_ABI InstListType::iterator eraseFromParent();
 
  327  LLVM_ABI bool isOnlyUserOfAnyOperand();
 
  332    return Opcode >= TermOpsBegin && Opcode < TermOpsEnd;
 
 
  336    return Opcode >= UnaryOpsBegin && Opcode < UnaryOpsEnd;
 
 
  339    return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd;
 
 
  343    return Opcode == UDiv || Opcode == SDiv || Opcode == URem || Opcode == SRem;
 
 
  347    return Opcode == FDiv || Opcode == FRem;
 
 
  352    return Opcode >= Shl && Opcode <= AShr;
 
 
  367    return Opcode == 
And || Opcode == 
Or || Opcode == 
Xor;
 
 
  376  static inline bool isCast(
unsigned Opcode) {
 
  377    return Opcode >= CastOpsBegin && Opcode < CastOpsEnd;
 
 
  382    return Opcode >= FuncletPadOpsBegin && Opcode < FuncletPadOpsEnd;
 
 
  389    case Instruction::CatchSwitch:
 
  390    case Instruction::CatchRet:
 
  391    case Instruction::CleanupRet:
 
  392    case Instruction::Invoke:
 
  393    case Instruction::Resume:
 
  394    case Instruction::CallBr:
 
 
  410  LLVM_ABI bool hasNonDebugLocLoopMetadata() 
const;
 
  430    if (KindID == LLVMContext::MD_dbg)
 
  431      return DbgLoc.getAsMDNode();
 
 
  439    return getMetadataImpl(Kind);
 
 
  448      getAllMetadataImpl(MDs);
 
 
  489  LLVM_ABI void addAnnotationMetadata(StringRef Annotation);
 
  494  LLVM_ABI void addAnnotationMetadata(SmallVector<StringRef> Annotations);
 
  496  LLVM_ABI AAMDNodes getAAMetadata() 
const;
 
  499  LLVM_ABI void setAAMetadata(
const AAMDNodes &
N);
 
  502  LLVM_ABI void setNoSanitizeMetadata();
 
  521  LLVM_ABI void setHasNoUnsignedWrap(
bool b = 
true);
 
  525  LLVM_ABI void setHasNoSignedWrap(
bool b = 
true);
 
  529  LLVM_ABI void setIsExact(
bool b = 
true);
 
  533  LLVM_ABI void setNonNeg(
bool b = 
true);
 
  550  LLVM_ABI void dropPoisonGeneratingFlags();
 
  556  LLVM_ABI void dropPoisonGeneratingMetadata();
 
  562  LLVM_ABI void dropPoisonGeneratingReturnAttributes();
 
  590  LLVM_ABI void dropUBImplyingAttrsAndMetadata(ArrayRef<unsigned> Keep = {});
 
  607  LLVM_ABI void setHasAllowReassoc(
bool B);
 
  622  LLVM_ABI void setHasNoSignedZeros(
bool B);
 
  627  LLVM_ABI void setHasAllowReciprocal(
bool B);
 
  632  LLVM_ABI void setHasAllowContract(
bool B);
 
  642  LLVM_ABI void setFastMathFlags(FastMathFlags FMF);
 
  647  LLVM_ABI void copyFastMathFlags(FastMathFlags FMF);
 
  702  LLVM_ABI void applyMergedLocation(DebugLoc LocA, DebugLoc LocB);
 
  708  LLVM_ABI void updateLocationAfterHoist();
 
  728  mergeDIAssignID(ArrayRef<
const Instruction *> SourceInstructions);
 
  734  getAllMetadataImpl(SmallVectorImpl<std::pair<
unsigned, MDNode *>> &) 
const;
 
  738  void updateDIAssignIDMapping(DIAssignID *ID);
 
  753    return Opcode == 
And || Opcode == 
Or || Opcode == 
Xor ||
 
  754           Opcode == 
Add || Opcode == 
Mul;
 
 
  784    return Opcode == 
And || Opcode == 
Or;
 
 
  798    return Opcode == 
Xor;
 
 
  844    case Instruction::Fence:
 
  845    case Instruction::CatchPad:
 
  846    case Instruction::CatchRet:
 
  847    case Instruction::Call:
 
  848    case Instruction::Invoke:
 
 
  881    case Instruction::CatchSwitch:
 
  882    case Instruction::CatchPad:
 
  883    case Instruction::CleanupPad:
 
  884    case Instruction::LandingPad:
 
 
  978    return V->getValueID() >= Value::InstructionVal;
 
 
  985#define  FIRST_TERM_INST(N)             TermOpsBegin = N, 
  986#define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N, 
  987#define   LAST_TERM_INST(N)             TermOpsEnd = N+1 
  988#include "llvm/IR/Instruction.def" 
 
  992#define  FIRST_UNARY_INST(N)             UnaryOpsBegin = N, 
  993#define HANDLE_UNARY_INST(N, OPC, CLASS) OPC = N, 
  994#define   LAST_UNARY_INST(N)             UnaryOpsEnd = N+1 
  995#include "llvm/IR/Instruction.def" 
 
  999#define  FIRST_BINARY_INST(N)             BinaryOpsBegin = N, 
 1000#define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N, 
 1001#define   LAST_BINARY_INST(N)             BinaryOpsEnd = N+1 
 1002#include "llvm/IR/Instruction.def" 
 
 1006#define  FIRST_MEMORY_INST(N)             MemoryOpsBegin = N, 
 1007#define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N, 
 1008#define   LAST_MEMORY_INST(N)             MemoryOpsEnd = N+1 
 1009#include "llvm/IR/Instruction.def" 
 
 1013#define  FIRST_CAST_INST(N)             CastOpsBegin = N, 
 1014#define HANDLE_CAST_INST(N, OPC, CLASS) OPC = N, 
 1015#define   LAST_CAST_INST(N)             CastOpsEnd = N+1 
 1016#include "llvm/IR/Instruction.def" 
 
 1020#define  FIRST_FUNCLETPAD_INST(N)             FuncletPadOpsBegin = N, 
 1021#define HANDLE_FUNCLETPAD_INST(N, OPC, CLASS) OPC = N, 
 1022#define   LAST_FUNCLETPAD_INST(N)             FuncletPadOpsEnd = N+1 
 1023#include "llvm/IR/Instruction.def" 
 
 1027#define  FIRST_OTHER_INST(N)             OtherOpsBegin = N, 
 1028#define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N, 
 1029#define   LAST_OTHER_INST(N)             OtherOpsEnd = N+1 
 1030#include "llvm/IR/Instruction.def" 
 
 1034  friend class SymbolTableListTraits<
Instruction, ilist_iterator_bits<
true>,
 
 1040  void setValueSubclassData(
unsigned short D) {
 
 1044  unsigned short getSubclassDataFromValue()
 const {
 
 1052  template <
typename BitfieldElement>
 
 1055        std::is_same<BitfieldElement, HasMetadataField>::value ||
 
 1057        "Must not overlap with the metadata bit");
 
 
 1061  template <
typename BitfieldElement>
 
 1064        std::is_same<BitfieldElement, HasMetadataField>::value ||
 
 1066        "Must not overlap with the metadata bit");
 
 1067    auto Storage = getSubclassDataFromValue();
 
 1069    setValueSubclassData(Storage);
 
 
 
Atomic ordering constants.
 
This file implements methods to test, set and extract typed bits from packed unsigned integers.
 
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
 
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
 
static StringRef getOpcodeName(uint8_t Opcode, uint8_t OpcodeBase)
 
static bool hasNoSignedWrap(BinaryOperator &I)
 
static bool hasNoUnsignedWrap(BinaryOperator &I)
 
static MemAccessTy getAccessType(const TargetTransformInfo &TTI, Instruction *Inst, Value *OperandVal)
Return the type of the memory being accessed.
 
static bool mayHaveSideEffects(MachineInstr &MI)
 
static bool isCommutative(Instruction *I, Value *ValWithUses)
 
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
 
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
 
static bool isAssociative(const COFFSection &Section)
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
LLVM Basic Block Representation.
 
A parsed version of the target data layout string in and methods for querying it.
 
Per-instruction record of debug-info.
 
Base class for non-instruction debug metadata records that have positions within IR.
 
Convenience struct for specifying and reasoning about fast-math flags.
 
BasicBlock * getBasicBlock()
 
InsertPosition(std::nullptr_t)
 
LLVM_ABI LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead", "BasicBlock::iterator") InsertPosition(Instruction *InsertBefore)
 
operator InstListType::iterator() const
 
DbgMarker * DebugMarker
Optional marker recording the position for debugging information that takes effect immediately before...
 
BitfieldElement::Type getSubclassData() const
 
typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT
 
bool hasMetadata(unsigned KindID) const
Return true if this instruction has the given type of metadata attached.
 
static bool isBinaryOp(unsigned Opcode)
 
bool isArithmeticShift() const
Return true if this is an arithmetic shift right.
 
typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT
 
bool hasMetadata(StringRef Kind) const
Return true if this instruction has the given type of metadata attached.
 
LLVM_ABI LLVM_DEPRECATED("Use iterators as instruction positions", "") void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
 
static bool isFPDivRem(unsigned Opcode)
 
LLVM_ABI iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(const Instruction *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere=std::nullopt, bool InsertAtHead=false)
Clone any debug-info attached to From onto this instruction.
 
static bool isBitwiseLogicOp(unsigned Opcode)
Determine if the Opcode is and/or/xor.
 
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.
 
LLVM_ABI bool hasPoisonGeneratingReturnAttributes() const LLVM_READONLY
Return true if this instruction has poison-generating attribute.
 
static bool isShift(unsigned Opcode)
Determine if the Opcode is one of the shift instructions.
 
LLVM_ABI bool mayWriteToMemory() const LLVM_READONLY
Return true if this instruction may modify memory.
 
static bool isSpecialTerminator(unsigned Opcode)
Returns true if the Opcode is a "special" terminator that does more than branch to a successor (e....
 
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange() const
Return a range over the DbgRecords attached to this instruction.
 
static bool isCast(unsigned Opcode)
Determine if the Opcode is one of the CastInst instructions.
 
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
 
LLVM_ABI bool isAssociative() const LLVM_READONLY
Return true if the instruction is associative:
 
Instruction & operator=(const Instruction &)=delete
 
LLVM_ABI void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
 
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
 
LLVM_ABI bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
 
typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT
 
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
 
LLVM_ABI void moveBefore(InstListType::iterator InsertPos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
 
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
 
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
 
LLVM_ABI void dropPoisonGeneratingReturnAttributes()
Drops return attributes that may generate poison.
 
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
 
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
 
static bool isIdempotent(unsigned Opcode)
 
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
 
bool isFuncletPad() const
 
bool isTerminator() const
 
LLVM_ABI bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
 
bool hasPoisonGeneratingAnnotations() const
Return true if this instruction has poison-generating flags, return attributes or metadata.
 
LLVM_ABI bool hasPoisonGeneratingFlags() const LLVM_READONLY
Return true if this operator has flags which may cause this instruction to evaluate to poison despite...
 
bool isNilpotent() const
Return true if the instruction is nilpotent:
 
LLVM_ABI bool mayReadFromMemory() const LLVM_READONLY
Return true if this instruction may read memory.
 
void dropPoisonGeneratingAnnotations()
Drops flags, return attributes and metadata that may generate poison.
 
const char * getOpcodeName() const
 
const Instruction * user_back() const
 
OperationEquivalenceFlags
When checking for operation equivalence (using isSameOperationAs) it is sometimes useful to ignore ce...
 
@ CompareIgnoringAlignment
Check for equivalence ignoring load/store alignment.
 
@ CompareUsingScalarTypes
Check for equivalence treating a type and a vector of that type as equivalent.
 
@ CompareUsingIntersectedAttrs
Check for equivalence with intersected callbase attrs.
 
MDNode * getMetadata(StringRef Kind) const
Get the metadata of given kind attached to this Instruction.
 
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Get all metadata attached to this Instruction.
 
bool isLogicalShift() const
Return true if this is a logical shift left or a logical shift right.
 
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
 
static bool isFuncletPad(unsigned Opcode)
Determine if the Opcode is one of the FuncletPadInst instructions.
 
LLVM_ABI void moveAfterPreserving(Instruction *MovePos)
See moveBeforePreserving .
 
static bool isUnaryOp(unsigned Opcode)
 
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
 
static bool isNilpotent(unsigned Opcode)
 
LLVM_ABI void dropPoisonGeneratingMetadata()
Drops metadata that may generate poison.
 
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
 
static bool isTerminator(unsigned Opcode)
 
Bitfield::Element< uint16_t, 0, 15 > OpaqueField
 
bool isFenceLike() const
Return true if this instruction behaves like a memory fence: it can load or store to memory location ...
 
LLVM_ABI std::optional< InstListType::iterator > getInsertionPointAfterDef()
Get the first insertion point at which the result of this instruction is defined.
 
LLVM_ABI void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs.
 
LLVM_ABI void moveBeforePreserving(InstListType::iterator MovePos)
Perform a moveBefore operation, while signalling that the caller intends to preserve the original ord...
 
LLVM_ABI bool hasPoisonGeneratingMetadata() const LLVM_READONLY
Return true if this instruction has poison-generating metadata.
 
Instruction(const Instruction &)=delete
 
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
 
static bool isIntDivRem(unsigned Opcode)
 
bool isIdempotent() const
Return true if the instruction is idempotent:
 
LLVM_ABI void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
 
friend class BasicBlock
Various leaf nodes.
 
SymbolTableList< Instruction, ilist_iterator_bits< true >, ilist_parent< BasicBlock > > InstListType
 
void setSubclassData(typename BitfieldElement::Type Value)
 
bool isSpecialTerminator() const
 
LLVM_ABI InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
 
A Module instance is used to store all the information related to an LLVM module.
 
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
 
StringRef - Represent a constant reference to a string, i.e.
 
List that automatically updates parent links and symbol tables.
 
The instances of the Type class are immutable: once they are created, they are never changed.
 
User(Type *ty, unsigned vty, AllocInfo AllocInfo)
 
LLVM Value Representation.
 
unsigned short getSubclassDataFromValue() const
 
user_iterator user_begin()
 
bool hasMetadata() const
Return true if this value has any metadata attached to it.
 
LLVM_ABI void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
 
unsigned getValueID() const
Return an ID for the concrete type of this object.
 
void setValueSubclassData(unsigned short D)
 
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
 
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
 
An efficient, type-erasing, non-owning reference to a callable.
 
ilist_node_with_parent()=default
 
typename base_list_type::iterator iterator
 
A range adaptor for a pair of iterators.
 
ilist_select_iterator_type< OptionsT, false, false > iterator
 
This file defines the ilist_node class template, which is a convenient base class for creating classe...
 
@ BasicBlock
Various leaf nodes.
 
friend class Instruction
Iterator for Instructions in a `BasicBlock.
 
This is an optimization pass for GlobalISel generic memory operations.
 
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange(DbgMarker *DebugMarker)
Inline helper to return a range of DbgRecords attached to a marker.
 
AtomicOrdering
Atomic ordering for LLVM's memory model.
 
@ Mul
Product of integers.
 
@ Xor
Bitwise or logical XOR of integers.
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
Implement std::hash so that hash_code can be used in STL containers.
 
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
 
Summary of memprof metadata on allocations.
 
Describes an element of a Bitfield.
 
static Bitfield::Type get(StorageType Packed)
Unpacks the field from the Packed value.
 
static constexpr bool isOverlapping()
Returns whether the two bitfields share common bits.
 
static void set(StorageType &Packed, typename Bitfield::Type Value)
Sets the typed value in the provided Packed value.
 
Use delete by default for iplist and ilist.
 
static void deleteNode(NodeTy *V)
 
Option to add a pointer to this list's owner in every node.