16 #ifndef LLVM_IR_INSTRTYPES_H
17 #define LLVM_IR_INSTRTYPES_H
38 Use *Ops,
unsigned NumOps,
40 :
Instruction(Ty, iType, Ops, NumOps, InsertBefore) {}
44 :
Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {}
80 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
104 void *
operator new(
size_t s) {
105 return User::operator
new(s, 1);
116 return I->
getOpcode() == Instruction::Alloca ||
119 I->
getOpcode() == Instruction::ExtractValue ||
123 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
143 const Twine &
Name, Instruction *InsertBefore);
149 void *
operator new(
size_t s) {
150 return User::operator
new(s, 2);
163 Instruction *InsertBefore = 0);
175 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
176 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
177 const Twine &Name = "") {\
178 return Create(Instruction::OPC, V1, V2, Name);\
180 #include "llvm/IR/Instruction.def"
181 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
182 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
183 const Twine &Name, BasicBlock *BB) {\
184 return Create(Instruction::OPC, V1, V2, Name, BB);\
186 #include "llvm/IR/Instruction.def"
187 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
188 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
189 const Twine &Name, Instruction *I) {\
190 return Create(Instruction::OPC, V1, V2, Name, I);\
192 #include "llvm/IR/Instruction.def"
195 const Twine &Name =
"") {
207 const Twine &Name, Instruction *
I) {
214 const Twine &Name =
"") {
226 const Twine &Name, Instruction *
I) {
233 const Twine &Name =
"") {
245 const Twine &Name, Instruction *
I) {
251 #define DEFINE_HELPERS(OPC, NUWNSWEXACT) \
252 static BinaryOperator *Create ## NUWNSWEXACT ## OPC \
253 (Value *V1, Value *V2, const Twine &Name = "") { \
254 return Create ## NUWNSWEXACT(Instruction::OPC, V1, V2, Name); \
256 static BinaryOperator *Create ## NUWNSWEXACT ## OPC \
257 (Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { \
258 return Create ## NUWNSWEXACT(Instruction::OPC, V1, V2, Name, BB); \
260 static BinaryOperator *Create ## NUWNSWEXACT ## OPC \
261 (Value *V1, Value *V2, const Twine &Name, Instruction *I) { \
262 return Create ## NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I); \
279 #undef DEFINE_HELPERS
287 static BinaryOperator *CreateNeg(Value *Op,
const Twine &Name =
"",
288 Instruction *InsertBefore = 0);
289 static BinaryOperator *CreateNeg(Value *Op,
const Twine &Name,
291 static BinaryOperator *CreateNSWNeg(Value *Op,
const Twine &Name =
"",
292 Instruction *InsertBefore = 0);
293 static BinaryOperator *CreateNSWNeg(Value *Op,
const Twine &Name,
295 static BinaryOperator *CreateNUWNeg(Value *Op,
const Twine &Name =
"",
296 Instruction *InsertBefore = 0);
297 static BinaryOperator *CreateNUWNeg(Value *Op,
const Twine &Name,
299 static BinaryOperator *CreateFNeg(Value *Op,
const Twine &Name =
"",
300 Instruction *InsertBefore = 0);
301 static BinaryOperator *CreateFNeg(Value *Op,
const Twine &Name,
303 static BinaryOperator *CreateNot(Value *Op,
const Twine &Name =
"",
304 Instruction *InsertBefore = 0);
305 static BinaryOperator *CreateNot(Value *Op,
const Twine &Name,
311 static bool isNeg(
const Value *V);
312 static bool isFNeg(
const Value *V,
bool IgnoreZeroSign=
false);
313 static bool isNot(
const Value *V);
319 static const Value *getNegArgument(
const Value *BinOp);
320 static Value *getNegArgument( Value *BinOp);
321 static const Value *getFNegArgument(
const Value *BinOp);
322 static Value *getFNegArgument( Value *BinOp);
323 static const Value *getNotArgument(
const Value *BinOp);
324 static Value *getNotArgument( Value *BinOp);
340 void setHasNoUnsignedWrap(
bool b =
true);
345 void setHasNoSignedWrap(
bool b =
true);
350 void setIsExact(
bool b =
true);
353 bool hasNoUnsignedWrap()
const;
356 bool hasNoSignedWrap()
const;
359 bool isExact()
const;
366 return isa<Instruction>(V) && classof(cast<Instruction>(V));
392 const Twine &NameStr =
"", Instruction *InsertBefore = 0)
393 : UnaryInstruction(Ty, iType, S, InsertBefore) {
399 : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
413 const Twine &Name =
"",
414 Instruction *InsertBefore = 0
431 static CastInst *CreateZExtOrBitCast(
434 const Twine &Name =
"",
435 Instruction *InsertBefore = 0
439 static CastInst *CreateZExtOrBitCast(
447 static CastInst *CreateSExtOrBitCast(
450 const Twine &Name =
"",
451 Instruction *InsertBefore = 0
455 static CastInst *CreateSExtOrBitCast(
474 const Twine &Name =
"",
475 Instruction *InsertBefore = 0
483 const Twine &Name =
"",
484 Instruction *InsertBefore = 0
500 const Twine &Name =
"",
501 Instruction *InsertBefore = 0
513 static CastInst *CreateTruncOrBitCast(
516 const Twine &Name =
"",
517 Instruction *InsertBefore = 0
521 static CastInst *CreateTruncOrBitCast(
529 static bool isCastable(
535 static bool isBitCastable(
555 bool isIntegerCast()
const;
562 bool isLosslessCast()
const;
573 static bool isNoopCast(
623 return isa<Instruction>(V) && classof(cast<Instruction>(V));
639 Instruction *InsertBefore = 0);
688 void *
operator new(
size_t s) {
689 return User::operator
new(s, 2);
697 unsigned short predicate,
Value *S1,
699 Instruction *InsertBefore = 0);
804 static bool isUnsigned(
unsigned short predicate);
808 static bool isSigned(
unsigned short predicate);
811 static bool isOrdered(
unsigned short predicate);
824 return I->
getOpcode() == Instruction::ICmp ||
828 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
833 if (
VectorType* vt = dyn_cast<VectorType>(opnd_type)) {
835 vt->getNumElements());
842 void setValueSubclassData(
unsigned short D) {
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
void setHasNoSignedWrap(bool b=true)
Abstract base class of comparison instructions.
static bool classof(const Instruction *I)
static IntegerType * getInt1Ty(LLVMContext &C)
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
static Instruction::CastOps isEliminableCastPair(const CastInst *CI, unsigned opcode, Type *DstTy, DataLayout *TD)
UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
static bool isOrdered(unsigned short predicate)
Determine if the predicate is an ordered operation.
Predicate getInversePredicate() const
Return the inverse of the instruction's predicate.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide more efficient getOperand methods.
bool isSigned() const
Determine if this instruction is using a signed comparison.
0 1 0 0 True if ordered and less than
virtual unsigned getNumSuccessorsV() const =0
1 1 1 0 True if unordered or not equal
static bool classof(const Value *V)
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
virtual void anchor() LLVM_OVERRIDE
bool isEquality() const
Determine if this is an equals/not equals predicate.
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics for subclasses.
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
1 0 0 1 True if unordered or equal
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
unsigned getSubclassDataFromInstruction() const
Base class of casting instructions.
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr, BasicBlock *InsertAtEnd)
Constructor with insert-at-end-of-block semantics for subclasses.
void setHasNoUnsignedWrap(bool b=true)
0 1 0 1 True if ordered and less than or equal
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
virtual TerminatorInst * clone_impl() const =0
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
void setSuccessor(unsigned idx, BasicBlock *B)
void setInstructionSubclassData(unsigned short D)
virtual void setSuccessorV(unsigned idx, BasicBlock *B)=0
UnaryInstruction(Type *Ty, unsigned iType, Value *V, Instruction *IB=0)
unsigned getNumSuccessors() const
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
initializer< Ty > init(const Ty &Val)
static bool isIntPredicate(Predicate P)
LLVM Basic Block Representation.
BasicBlock * getSuccessor(unsigned idx) const
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
bool isIntPredicate() const
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
bool isFalseWhenEqual() const
Determine if this is false when both operands are the same.
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
0 1 1 1 True if ordered (no nans)
static bool classof(const Value *V)
Type * getSrcTy() const
Return the source type, as a convenience.
Predicate getPredicate() const
Return the predicate for this instruction.
static bool classof(const Instruction *I)
1 1 1 1 Always true (always folded)
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
bool isCommutative() const
Determine if this CmpInst is commutative.
1 1 0 1 True if unordered, less than, or equal
void swapOperands()
Swap the operands and adjust predicate accordingly to retain the same comparison. ...
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
virtual BasicBlock * getSuccessorV(unsigned idx) const =0
void setIsExact(bool b=true)
bool isTerminator() const
0 0 1 0 True if ordered and greater than
BinaryOps getOpcode() const
TerminatorInst(Type *Ty, Instruction::TermOps iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
1 1 0 0 True if unordered or less than
bool isTrueWhenEqual() const
Determine if this is true when both operands are the same.
Type * getDestTy() const
Return the destination type, as a convenience.
#define DEFINE_HELPERS(OPC, NUWNSWEXACT)
Predicate getSwappedPredicate() const
Return the predicate as if the operands were swapped.
void setValueSubclassData(unsigned short D)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
#define LLVM_DELETED_FUNCTION
static bool isFPPredicate(Predicate P)
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
bool isFPPredicate() const
static CmpInst * Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const Twine &Name="", Instruction *InsertBefore=0)
Create a CmpInst.
unsigned greater or equal
static bool classof(const Value *V)
0 1 1 0 True if ordered and operands are unequal
1 0 1 0 True if unordered or greater than
OtherOps getOpcode() const
Get the opcode casted to the right type.
static bool classof(const Value *V)
bool isUnsigned() const
Determine if this instruction is using an unsigned comparison.
0 0 0 1 True if ordered and equal
LLVM Value Representation.
1 0 1 1 True if unordered, greater than, or equal
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
static bool classof(const Value *V)
static VectorType * get(Type *ElementType, unsigned NumElements)
static bool isUnordered(unsigned short predicate)
Determine if the predicate is an unordered operation.
TerminatorInst(Type *Ty, Instruction::TermOps iType, Use *Ops, unsigned NumOps, Instruction *InsertBefore=0)
static bool classof(const Instruction *I)
0 0 1 1 True if ordered and greater than or equal
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
0 0 0 0 Always false (always folded)