15 #ifndef LLVM_IR_INSTRUCTION_H
16 #define LLVM_IR_INSTRUCTION_H
61 HasMetadataBit = 1 << 15
123 return OpCode >= TermOpsBegin && OpCode < TermOpsEnd;
127 return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd;
132 return Opcode >= Shl && Opcode <= AShr;
147 static inline bool isCast(
unsigned OpCode) {
148 return OpCode >= CastOpsBegin && OpCode < CastOpsEnd;
157 bool hasMetadata()
const {
return DbgLoc || hasMetadataHashEntry(); }
162 return hasMetadataHashEntry();
169 return getMetadataImpl(KindID);
176 return getMetadataImpl(Kind);
185 getAllMetadataImpl(MDs);
193 getAllMetadataOtherThanDebugLocImpl(MDs);
218 unsigned IDs[] = {ID1, ID2};
293 bool hasMetadataHashEntry()
const {
294 return (getSubclassDataFromValue() & HasMetadataBit) != 0;
298 MDNode *getMetadataImpl(
unsigned KindID)
const;
299 MDNode *getMetadataImpl(StringRef
Kind)
const;
301 getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, MDNode *>> &)
const;
302 void getAllMetadataOtherThanDebugLocImpl(
303 SmallVectorImpl<std::pair<unsigned, MDNode *>> &)
const;
304 void clearMetadataHashEntries();
437 return V->
getValueID() >= Value::InstructionVal;
444 #define FIRST_TERM_INST(N) TermOpsBegin = N,
445 #define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N,
446 #define LAST_TERM_INST(N) TermOpsEnd = N+1
447 #include "llvm/IR/Instruction.def"
451 #define FIRST_BINARY_INST(N) BinaryOpsBegin = N,
452 #define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N,
453 #define LAST_BINARY_INST(N) BinaryOpsEnd = N+1
454 #include "llvm/IR/Instruction.def"
458 #define FIRST_MEMORY_INST(N) MemoryOpsBegin = N,
459 #define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N,
460 #define LAST_MEMORY_INST(N) MemoryOpsEnd = N+1
461 #include "llvm/IR/Instruction.def"
465 #define FIRST_CAST_INST(N) CastOpsBegin = N,
466 #define HANDLE_CAST_INST(N, OPC, CLASS) OPC = N,
467 #define LAST_CAST_INST(N) CastOpsEnd = N+1
468 #include "llvm/IR/Instruction.def"
472 #define FIRST_OTHER_INST(N) OtherOpsBegin = N,
473 #define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N,
474 #define LAST_OTHER_INST(N) OtherOpsEnd = N+1
475 #include "llvm/IR/Instruction.def"
480 void setValueSubclassData(
unsigned short D) {
483 unsigned short getSubclassDataFromValue()
const {
487 void setHasMetadataHashEntry(
bool V) {
488 setValueSubclassData((getSubclassDataFromValue() & ~HasMetadataBit) |
489 (V ? HasMetadataBit : 0));
500 assert((D & HasMetadataBit) == 0 &&
"Out of range value put into field");
501 setValueSubclassData((getSubclassDataFromValue() & HasMetadataBit) | D);
505 return getSubclassDataFromValue() & ~HasMetadataBit;
536 return static_cast<PT
>(
P);
538 enum { NumLowBitsAvailable = 2 };
bool isArithmeticShift() const
isArithmeticShift - Return true if this is an arithmetic shift right.
bool isNilpotent() const
isNilpotent - Return true if the instruction is nilpotent:
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction, which must be an operator which supports these flags.
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
A Module instance is used to store all the information related to an LLVM module. ...
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
bool isUsedOutsideOfBlock(const BasicBlock *BB) const
isUsedOutsideOfBlock - Return true if there are any uses of this instruction in blocks other than the...
bool mayHaveSideEffects() const
mayHaveSideEffects - Return true if the instruction may have side effects.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
getAllMetadata - Get all metadata attached to this Instruction.
PointerLikeTypeTraits - This is a traits object that is used to handle pointer types and things that ...
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
void dropUnknownMetadata(unsigned ID1, unsigned ID2)
bool mayReturn() const
mayReturn - Return true if this is a function that may return.
static bool isShift(unsigned Opcode)
Determine if the Opcode is one of the shift instructions.
unsigned getSubclassDataFromInstruction() const
static void * getAsVoidPointer(PT P)
bool isIdenticalTo(const Instruction *I) const
isIdenticalTo - Return true if the specified instruction is exactly identical to the current one...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static PT getFromVoidPointer(void *P)
A Use represents the edge between a Value definition and its users.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
Check for equivalence ignoring load/store alignment.
Instruction * clone() const
clone() - Create a copy of 'this' instruction that is identical in all ways except the following: ...
OperationEquivalenceFlags
When checking for operation equivalence (using isSameOperationAs) it is sometimes useful to ignore ce...
Instruction * provideInitialHead() const
Instruction * ensureHead(Instruction *) const
Check for equivalence treating a type and a vector of that type as equivalent.
bool mayReadFromMemory() const
mayReadFromMemory - Return true if this instruction may read memory.
bool isAssociative() const
isAssociative - Return true if the instruction is associative:
void setHasUnsafeAlgebra(bool B)
Set or clear the unsafe-algebra flag on this instruction, which must be an operator which supports th...
bool hasUnsafeAlgebra() const
Determine whether the unsafe-algebra flag is set.
static bool isBinaryOp(unsigned Opcode)
bool isLogicalShift() const
isLogicalShift - Return true if this is a logical shift left or a logical shift right.
static void noteHead(Instruction *, Instruction *)
void setInstructionSubclassData(unsigned short D)
const char * getOpcodeName() const
bool isAtomic() const
isAtomic - Return true if this instruction has an AtomicOrdering of unordered or higher.
bool mayReadOrWriteMemory() const
mayReadOrWriteMemory - Return true if this instruction may read or write memory.
static bool isTerminator(unsigned OpCode)
void setDebugLoc(DebugLoc Loc)
setDebugLoc - Set the debug location information for this instruction.
bool isIdenticalToWhenDefined(const Instruction *I) const
isIdenticalToWhenDefined - This is like isIdenticalTo, except that it ignores the SubclassOptionalDat...
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction...
void setAAMetadata(const AAMDNodes &N)
setAAMetadata - Sets the metadata on this instruction from the AAMDNodes structure.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
getAllMetadataOtherThanDebugLoc - This does the same thing as getAllMetadata, except that it filters ...
void dropUnknownMetadata(unsigned ID1)
bool hasMetadata() const
hasMetadata() - Return true if this instruction has any metadata attached to it.
const DebugLoc & getDebugLoc() const
getDebugLoc - Return the debug location for this node as a DebugLoc.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
unsigned getValueID() const
Return an ID for the concrete type of this object.
bool isCommutative() const
isCommutative - Return true if the instruction is commutative:
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
iplist - The subset of list functionality that can safely be used on nodes of polymorphic types...
void setMetadata(unsigned KindID, MDNode *Node)
setMetadata - Set the metadata of the specified kind to the specified node.
bool mayWriteToMemory() const
mayWriteToMemory - Return true if this instruction may modify memory.
bool isTerminator() const
static void destroySentinel(Instruction *)
MDNode * getMetadata(StringRef Kind) const
getMetadata - Get the metadata of given kind attached to this Instruction.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Instruction * user_back()
user_back - Specialize the methods defined in Value, as we know that an instruction can only be used ...
MDNode * getMetadata(unsigned KindID) const
getMetadata - Get the metadata of given kind attached to this Instruction.
const Instruction * user_back() const
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
static bool isCast(unsigned OpCode)
Determine if the OpCode is one of the CastInst instructions.
void setValueSubclassData(unsigned short D)
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing basic block, but does not delete it...
bool mayThrow() const
mayThrow - Return true if this instruction may throw an exception.
unsigned short getSubclassDataFromValue() const
ilist_node - Base class that provides next/prev services for nodes that use ilist_nextprev_traits or ...
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
getAAMetadata - Fills the AAMDNodes structure with AA metadata from this instruction.
bool isIdempotent() const
isIdempotent - Return true if the instruction is idempotent:
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction...
bool hasNoInfs() const
Determine whether the no-infs flag is set.
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
bool hasMetadataOtherThanDebugLoc() const
hasMetadataOtherThanDebugLoc - Return true if this instruction has metadata attached to it other than...
user_iterator user_begin()
const ARM::ArchExtKind Kind
LLVM Value Representation.
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
void dropUnknownMetadata()
void moveBefore(Instruction *MovePos)
moveBefore - Unlink this instruction from its current basic block and insert it into the basic block ...
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
bool isSameOperationAs(const Instruction *I, unsigned flags=0) const
This function determines if the specified instruction executes the same operation as the current one...
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
const BasicBlock * getParent() const