LLVM API Documentation
#include <InstrTypes.h>
Public Types | |
| enum | Predicate { FCMP_FALSE = 0, FCMP_OEQ = 1, FCMP_OGT = 2, FCMP_OGE = 3, FCMP_OLT = 4, FCMP_OLE = 5, FCMP_ONE = 6, FCMP_ORD = 7, FCMP_UNO = 8, FCMP_UEQ = 9, FCMP_UGT = 10, FCMP_UGE = 11, FCMP_ULT = 12, FCMP_ULE = 13, FCMP_UNE = 14, FCMP_TRUE = 15, FIRST_FCMP_PREDICATE = FCMP_FALSE, LAST_FCMP_PREDICATE = FCMP_TRUE, BAD_FCMP_PREDICATE = FCMP_TRUE + 1, ICMP_EQ = 32, ICMP_NE = 33, ICMP_UGT = 34, ICMP_UGE = 35, ICMP_ULT = 36, ICMP_ULE = 37, ICMP_SGT = 38, ICMP_SGE = 39, ICMP_SLT = 40, ICMP_SLE = 41, FIRST_ICMP_PREDICATE = ICMP_EQ, LAST_ICMP_PREDICATE = ICMP_SLE, BAD_ICMP_PREDICATE = ICMP_SLE + 1 } |
Public Member Functions | |
| void * | operator new (size_t s) |
| OtherOps | getOpcode () const |
| Get the opcode casted to the right type. | |
| Predicate | getPredicate () const |
| Return the predicate for this instruction. | |
| void | setPredicate (Predicate P) |
| Set the predicate for this instruction to the specified value. | |
| Predicate | getInversePredicate () const |
| Return the inverse of the instruction's predicate. | |
| Predicate | getSwappedPredicate () const |
| Return the predicate as if the operands were swapped. | |
| DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value) | |
| Provide more efficient getOperand methods. | |
| void | swapOperands () |
| Swap the operands and adjust predicate accordingly to retain the same comparison. | |
| bool | isCommutative () |
| Determine if this CmpInst is commutative. | |
| bool | isEquality () |
| Determine if this is an equals/not equals predicate. | |
Static Public Member Functions | |
| static CmpInst * | Create (LLVMContext &Context, OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const Twine &Name="", Instruction *InsertBefore=0) |
| Create a CmpInst. | |
| static CmpInst * | Create (OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const Twine &Name, BasicBlock *InsertAtEnd) |
| Create a CmpInst. | |
| static Predicate | getInversePredicate (Predicate pred) |
| Return the inverse of a given predicate. | |
| static Predicate | getSwappedPredicate (Predicate pred) |
| Return the predicate as if the operands were swapped. | |
| static bool | isUnsigned (unsigned short predicate) |
| Determine if the predicate is an unsigned operation. | |
| static bool | isSigned (unsigned short predicate) |
| Determine if the predicate is an signed operation. | |
| static bool | isOrdered (unsigned short predicate) |
| Determine if the predicate is an ordered operation. | |
| static bool | isUnordered (unsigned short predicate) |
| Determine if the predicate is an unordered operation. | |
| static bool | classof (const CmpInst *) |
| Methods for support type inquiry through isa, cast, and dyn_cast:. | |
| static bool | classof (const Instruction *I) |
| Methods for support type inquiry through isa, cast, and dyn_cast:. | |
| static bool | classof (const Value *V) |
| static const Type * | makeCmpResultType (const Type *opnd_type) |
| Create a result type for fcmp/icmp. | |
Protected Member Functions | |
| CmpInst (const Type *ty, Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, const Twine &Name="", Instruction *InsertBefore=0) | |
| CmpInst (const Type *ty, Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, const Twine &Name, BasicBlock *InsertAtEnd) | |
This class is the base class for the comparison instructions.
Definition at line 1135 of file InstrTypes.h.
This enumeration lists the possible predicates for CmpInst subclasses. Values in the range 0-31 are reserved for FCmpInst, while values in the range 32-64 are reserved for ICmpInst. This is necessary to ensure the predicate values are not overlapping between the classes.
Definition at line 1152 of file InstrTypes.h.
| CmpInst::CmpInst | ( | const Type * | ty, | |
| Instruction::OtherOps | op, | |||
| unsigned short | pred, | |||
| Value * | LHS, | |||
| Value * | RHS, | |||
| const Twine & | Name = "", |
|||
| Instruction * | InsertBefore = 0 | |||
| ) | [protected] |
| CmpInst::CmpInst | ( | const Type * | ty, | |
| Instruction::OtherOps | op, | |||
| unsigned short | pred, | |||
| Value * | LHS, | |||
| Value * | RHS, | |||
| const Twine & | Name, | |||
| BasicBlock * | InsertAtEnd | |||
| ) | [protected] |
| void* llvm::CmpInst::operator new | ( | size_t | s | ) | [inline] |
| CmpInst * CmpInst::Create | ( | LLVMContext & | Context, | |
| OtherOps | Op, | |||
| unsigned short | predicate, | |||
| Value * | S1, | |||
| Value * | S2, | |||
| const Twine & | Name = "", |
|||
| Instruction * | InsertBefore = 0 | |||
| ) | [static] |
Create a CmpInst.
Construct a compare instruction, given the opcode, the predicate and the two operands. Optionally (if InstBefore is specified) insert the instruction into a BasicBlock right before the specified instruction. The specified Instruction is allowed to be a dereferenced end iterator.
Definition at line 2509 of file Instructions.cpp.
Referenced by OptimizeCmpExpression().
| CmpInst * CmpInst::Create | ( | OtherOps | Op, | |
| unsigned short | predicate, | |||
| Value * | S1, | |||
| Value * | S2, | |||
| const Twine & | Name, | |||
| BasicBlock * | InsertAtEnd | |||
| ) | [static] |
Create a CmpInst.
Construct a compare instruction, given the opcode, the predicate and the two operands. Also automatically insert this instruction to the end of the BasicBlock specified.
Definition at line 2530 of file Instructions.cpp.
| OtherOps llvm::CmpInst::getOpcode | ( | ) | const [inline] |
Get the opcode casted to the right type.
Reimplemented from llvm::Instruction.
Definition at line 1210 of file InstrTypes.h.
Referenced by dyn_castFoldableMul(), and OptimizeCmpExpression().
| Predicate llvm::CmpInst::getPredicate | ( | ) | const [inline] |
Return the predicate for this instruction.
Definition at line 1215 of file InstrTypes.h.
Referenced by llvm::ICmpInst::clone(), llvm::FCmpInst::clone(), getICmpCode(), OptimizeCmpExpression(), OptimizeGlobalAddressOfMalloc(), llvm::Interpreter::visitFCmpInst(), and llvm::Interpreter::visitICmpInst().
| void llvm::CmpInst::setPredicate | ( | Predicate | P | ) | [inline] |
Set the predicate for this instruction to the specified value.
Definition at line 1218 of file InstrTypes.h.
| Predicate llvm::CmpInst::getInversePredicate | ( | ) | const [inline] |
Return the inverse of the instruction's predicate.
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
Definition at line 1224 of file InstrTypes.h.
| CmpInst::Predicate CmpInst::getInversePredicate | ( | Predicate | pred | ) | [static] |
Return the inverse of a given predicate.
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
pred. Definition at line 2560 of file Instructions.cpp.
References FCMP_FALSE, FCMP_OEQ, FCMP_OGE, FCMP_OGT, FCMP_OLE, FCMP_OLT, FCMP_ONE, FCMP_ORD, FCMP_TRUE, FCMP_UEQ, FCMP_UGE, FCMP_UGT, FCMP_ULE, FCMP_ULT, FCMP_UNE, FCMP_UNO, ICMP_EQ, ICMP_NE, ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, and ICMP_ULT.
| Predicate llvm::CmpInst::getSwappedPredicate | ( | ) | const [inline] |
Return the predicate as if the operands were swapped.
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
Definition at line 1240 of file InstrTypes.h.
Referenced by llvm::ConstantFoldCompareInstruction(), evaluateFCmpRelation(), and evaluateICmpRelation().
| CmpInst::Predicate CmpInst::getSwappedPredicate | ( | Predicate | pred | ) | [static] |
Return the predicate as if the operands were swapped.
This is a static version that you can use without an instruction available.
Definition at line 2665 of file Instructions.cpp.
References FCMP_FALSE, FCMP_OEQ, FCMP_OGE, FCMP_OGT, FCMP_OLE, FCMP_OLT, FCMP_ONE, FCMP_ORD, FCMP_TRUE, FCMP_UEQ, FCMP_UGE, FCMP_UGT, FCMP_ULE, FCMP_ULT, FCMP_UNE, FCMP_UNO, ICMP_EQ, ICMP_NE, ICMP_SGE, ICMP_SGT, ICMP_SLE, ICMP_SLT, ICMP_UGE, ICMP_UGT, ICMP_ULE, and ICMP_ULT.
| llvm::CmpInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS | ( | Value | ) |
Provide more efficient getOperand methods.
| void CmpInst::swapOperands | ( | ) |
Swap the operands and adjust predicate accordingly to retain the same comparison.
This is just a convenience that dispatches to the subclasses.
Reimplemented in llvm::ICmpInst, and llvm::FCmpInst.
Definition at line 2540 of file Instructions.cpp.
References IC.
| bool CmpInst::isCommutative | ( | ) |
Determine if this CmpInst is commutative.
This is just a convenience that dispatches to the subclasses.
Definition at line 2547 of file Instructions.cpp.
References IC.
| bool CmpInst::isEquality | ( | ) |
Determine if this is an equals/not equals predicate.
This is just a convenience that dispatches to the subclasses.
Definition at line 2553 of file Instructions.cpp.
References IC.
Determine if the predicate is an signed operation.
Definition at line 2703 of file Instructions.cpp.
References ICMP_SGE, ICMP_SGT, ICMP_SLE, and ICMP_SLT.
Referenced by llvm::ConstantFoldCompareInstruction().
Methods for support type inquiry through isa, cast, and dyn_cast:.
Definition at line 1280 of file InstrTypes.h.
| static bool llvm::CmpInst::classof | ( | const Instruction * | ) | [inline, static] |
Methods for support type inquiry through isa, cast, and dyn_cast:.
Reimplemented from llvm::Instruction.
Reimplemented in llvm::ICmpInst, and llvm::FCmpInst.
Definition at line 1281 of file InstrTypes.h.
Reimplemented from llvm::Instruction.
Reimplemented in llvm::ICmpInst, and llvm::FCmpInst.
Definition at line 1285 of file InstrTypes.h.