15 #ifndef LLVM_IR_INSTRUCTION_H
16 #define LLVM_IR_INSTRUCTION_H
28 template<
typename ValueSubClass,
typename ItemParentClass>
29 class SymbolTableListTraits;
41 HasMetadataBit = 1 << 15
94 return OpCode >= TermOpsBegin && OpCode < TermOpsEnd;
98 return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd;
103 return Opcode >= Shl && Opcode <= AShr;
118 static inline bool isCast(
unsigned OpCode) {
119 return OpCode >= CastOpsBegin && OpCode < CastOpsEnd;
129 return !DbgLoc.
isUnknown() || hasMetadataHashEntry();
135 return hasMetadataHashEntry();
142 return getMetadataImpl(KindID);
149 return getMetadataImpl(Kind);
157 getAllMetadataImpl(MDs);
165 getAllMetadataOtherThanDebugLocImpl(MDs);
236 bool hasMetadataHashEntry()
const {
237 return (getSubclassDataFromValue() & HasMetadataBit) != 0;
241 MDNode *getMetadataImpl(
unsigned KindID)
const;
242 MDNode *getMetadataImpl(StringRef
Kind)
const;
243 void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)
const;
244 void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<
unsigned,
246 void clearMetadataHashEntries();
381 #define FIRST_TERM_INST(N) TermOpsBegin = N,
382 #define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N,
383 #define LAST_TERM_INST(N) TermOpsEnd = N+1
384 #include "llvm/IR/Instruction.def"
388 #define FIRST_BINARY_INST(N) BinaryOpsBegin = N,
389 #define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N,
390 #define LAST_BINARY_INST(N) BinaryOpsEnd = N+1
391 #include "llvm/IR/Instruction.def"
395 #define FIRST_MEMORY_INST(N) MemoryOpsBegin = N,
396 #define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N,
397 #define LAST_MEMORY_INST(N) MemoryOpsEnd = N+1
398 #include "llvm/IR/Instruction.def"
402 #define FIRST_CAST_INST(N) CastOpsBegin = N,
403 #define HANDLE_CAST_INST(N, OPC, CLASS) OPC = N,
404 #define LAST_CAST_INST(N) CastOpsEnd = N+1
405 #include "llvm/IR/Instruction.def"
409 #define FIRST_OTHER_INST(N) OtherOpsBegin = N,
410 #define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N,
411 #define LAST_OTHER_INST(N) OtherOpsEnd = N+1
412 #include "llvm/IR/Instruction.def"
417 void setValueSubclassData(
unsigned short D) {
420 unsigned short getSubclassDataFromValue()
const {
424 void setHasMetadataHashEntry(
bool V) {
425 setValueSubclassData((getSubclassDataFromValue() & ~HasMetadataBit) |
426 (V ? HasMetadataBit : 0));
437 assert((D & HasMetadataBit) == 0 &&
"Out of range value put into field");
438 setValueSubclassData((getSubclassDataFromValue() & HasMetadataBit) | D);
442 return getSubclassDataFromValue() & ~HasMetadataBit;
460 return static_cast<PT
>(
P);
462 enum { NumLowBitsAvailable = 2 };
bool isArithmeticShift() const
isArithmeticShift - Return true if this is an arithmetic shift right.
void setFastMathFlags(FastMathFlags FMF)
void setHasNoNaNs(bool B)
bool isUsedOutsideOfBlock(const BasicBlock *BB) const
bool mayHaveSideEffects() const
FastMathFlags getFastMathFlags() const
MDNode - a tuple of other values.
void setDebugLoc(const DebugLoc &Loc)
setDebugLoc - Set the debug location information for this instruction.
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
bool isUnknown() const
isUnknown - Return true if this is an unknown location.
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
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
static PT getFromVoidPointer(void *P)
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
Check for equivalence ignoring load/store alignment.
Instruction * clone() const
OperationEquivalenceFlags
bool mayReadFromMemory() const
bool isAssociative() const
void setHasUnsafeAlgebra(bool B)
bool hasUnsafeAlgebra() const
Determine whether the unsafe-algebra flag is set.
static bool isBinaryOp(unsigned Opcode)
bool isLogicalShift() const
void setInstructionSubclassData(unsigned short D)
const char * getOpcodeName() const
bool mayReadOrWriteMemory() const
static bool isTerminator(unsigned OpCode)
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
bool isIdenticalToWhenDefined(const Instruction *I) const
void insertBefore(Instruction *InsertPos)
LLVM Basic Block Representation.
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
bool isCommutative() const
void setHasNoInfs(bool B)
void setMetadata(unsigned KindID, MDNode *Node)
bool mayWriteToMemory() const
bool isTerminator() const
MDNode * getMetadata(StringRef Kind) const
MDNode * getMetadata(unsigned KindID) const
static bool isCast(unsigned OpCode)
Determine if the OpCode is one of the CastInst instructions.
void copyFastMathFlags(const Instruction *I)
Copy I's fast-math flags.
void setValueSubclassData(unsigned short D)
#define LLVM_DELETED_FUNCTION
const Instruction * use_back() const
unsigned short getSubclassDataFromValue() const
bool isIdempotent() const
void insertAfter(Instruction *InsertPos)
bool hasNoInfs() const
Determine whether the no-infs flag is set.
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
bool hasMetadataOtherThanDebugLoc() const
virtual Instruction * clone_impl() const =0
LLVM Value Representation.
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
void moveBefore(Instruction *MovePos)
Convenience struct for specifying and reasoning about fast-math flags.
bool isSameOperationAs(const Instruction *I, unsigned flags=0) const
Determine if one instruction is the same operation as another.
void setHasNoSignedZeros(bool B)
void setHasAllowReciprocal(bool B)
const BasicBlock * getParent() const