LLVM API Documentation

llvm::ICmpInst Class Reference

Represent an integer comparison operator. More...

#include <Instructions.h>

Inheritance diagram for llvm::ICmpInst:
[legend]
Collaboration diagram for llvm::ICmpInst:
[legend]

List of all members.

Public Member Functions

 ICmpInst (Instruction *InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
 Constructor with insert-before-instruction semantics.
 ICmpInst (BasicBlock &InsertAtEnd, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
 Constructor with insert-at-end semantics.
 ICmpInst (LLVMContext &Context, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
 Constructor with no-insertion semantics.
Predicate getSignedPredicate () const
 Return the signed version of the predicate.
Predicate getUnsignedPredicate () const
 Return the unsigned version of the predicate.
bool isEquality () const
bool isCommutative () const
 Determine if this relation is commutative.
bool isRelational () const
bool isSignedPredicate () const
 Determine if this instruction's predicate is signed.
bool isTrueWhenEqual ()
 Determine if the ICmpInst returns true when both operands are equal.
void swapOperands ()
 Swap operands and adjust predicate.
virtual ICmpInst * clone (LLVMContext &Context) const

Static Public Member Functions

static Predicate getSignedPredicate (Predicate pred)
 Return the signed version of the predicate.
static Predicate getUnsignedPredicate (Predicate pred)
 Return the unsigned version of the predicate.
static bool isEquality (Predicate P)
static bool isRelational (Predicate P)
static bool isSignedPredicate (Predicate pred)
 Determine if the predicate is signed.
static bool isTrueWhenEqual (ICmpInst::Predicate pred)
 Determine if the icmp is true when both operands are equal.
static ConstantRange makeConstantRange (Predicate pred, const APInt &C)
 Make a ConstantRange for a relation with a constant value.
static bool classof (const ICmpInst *)
static bool classof (const Instruction *I)
 Methods for support type inquiry through isa, cast, and dyn_cast:.
static bool classof (const Value *V)


Detailed Description

Represent an integer comparison operator.

This instruction compares its operands according to the predicate given to the constructor. It only operates on integers or pointers. The operands must be identical types.

Definition at line 653 of file Instructions.h.


Constructor & Destructor Documentation

llvm::ICmpInst::ICmpInst ( Instruction *  InsertBefore,
Predicate  pred,
Value *  LHS,
Value *  RHS,
const Twine &  NameStr = "" 
) [inline]

Constructor with insert-before-instruction semantics.

Parameters:
InsertBefore  Where to insert
pred  The predicate to use for the comparison
LHS  The left-hand-side of the expression
RHS  The right-hand-side of the expression
NameStr  Name of the instruction

Definition at line 656 of file Instructions.h.

References llvm::CmpInst::FIRST_ICMP_PREDICATE, llvm::Intrinsic::getType(), and llvm::CmpInst::LAST_ICMP_PREDICATE.

Referenced by clone().

llvm::ICmpInst::ICmpInst ( BasicBlock &  InsertAtEnd,
Predicate  pred,
Value *  LHS,
Value *  RHS,
const Twine &  NameStr = "" 
) [inline]

Constructor with insert-at-end semantics.

Parameters:
InsertAtEnd  Block to insert into.
pred  The predicate to use for the comparison
LHS  The left-hand-side of the expression
RHS  The right-hand-side of the expression
NameStr  Name of the instruction

Definition at line 677 of file Instructions.h.

References llvm::CmpInst::FIRST_ICMP_PREDICATE, llvm::Intrinsic::getType(), and llvm::CmpInst::LAST_ICMP_PREDICATE.

llvm::ICmpInst::ICmpInst ( LLVMContext &  Context,
Predicate  pred,
Value *  LHS,
Value *  RHS,
const Twine &  NameStr = "" 
) [inline]

Constructor with no-insertion semantics.

Parameters:
Context  Context to construct within
pred  The predicate to use for the comparison
LHS  The left-hand-side of the expression
RHS  The right-hand-side of the expression
NameStr  Name of the instruction

Definition at line 698 of file Instructions.h.

References llvm::CmpInst::FIRST_ICMP_PREDICATE, llvm::Intrinsic::getType(), and llvm::CmpInst::LAST_ICMP_PREDICATE.


Member Function Documentation

Predicate llvm::ICmpInst::getSignedPredicate (  )  const [inline]

Return the signed version of the predicate.

For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.

Returns:
the predicate that would be the result if the operand were regarded as signed.

Definition at line 721 of file Instructions.h.

References getPredicate().

ICmpInst::Predicate ICmpInst::getSignedPredicate ( Predicate  pred  )  [static]

Return the signed version of the predicate.

This is a static version that you can use without an instruction.

Definition at line 2593 of file Instructions.cpp.

References llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, and llvm::CmpInst::ICMP_ULT.

Predicate llvm::ICmpInst::getUnsignedPredicate (  )  const [inline]

Return the unsigned version of the predicate.

For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.

Returns:
the predicate that would be the result if the operand were regarded as unsigned.

Definition at line 733 of file Instructions.h.

References getPredicate().

ICmpInst::Predicate ICmpInst::getUnsignedPredicate ( Predicate  pred  )  [static]

Return the unsigned version of the predicate.

This is a static version that you can use without an instruction.

Definition at line 2606 of file Instructions.cpp.

References llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, and llvm::CmpInst::ICMP_ULT.

static bool llvm::ICmpInst::isEquality ( Predicate  P  )  [inline, static]

isEquality - Return true if this predicate is either EQ or NE. This also tests for commutativity.

Definition at line 743 of file Instructions.h.

bool llvm::ICmpInst::isEquality (  )  const [inline]

isEquality - Return true if this predicate is either EQ or NE. This also tests for commutativity.

Definition at line 749 of file Instructions.h.

References getPredicate().

bool llvm::ICmpInst::isCommutative (  )  const [inline]

Determine if this relation is commutative.

Returns:
true if the predicate of this ICmpInst is commutative

Reimplemented from llvm::Instruction.

Definition at line 755 of file Instructions.h.

bool llvm::ICmpInst::isRelational (  )  const [inline]

isRelational - Return true if the predicate is relational (not EQ or NE).

Definition at line 759 of file Instructions.h.

static bool llvm::ICmpInst::isRelational ( Predicate  P  )  [inline, static]

isRelational - Return true if the predicate is relational (not EQ or NE).

Definition at line 765 of file Instructions.h.

bool llvm::ICmpInst::isSignedPredicate (  )  const [inline]

Determine if this instruction's predicate is signed.

Returns:
true if the predicate of this ICmpInst is signed, false otherwise

Definition at line 771 of file Instructions.h.

References getPredicate().

bool ICmpInst::isSignedPredicate ( Predicate  pred  )  [static]

Determine if the predicate is signed.

Returns:
true if the predicate provided is signed, false otherwise

Definition at line 2619 of file Instructions.cpp.

References llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, and llvm::CmpInst::ICMP_ULT.

static bool llvm::ICmpInst::isTrueWhenEqual ( ICmpInst::Predicate  pred  )  [inline, static]

Determine if the icmp is true when both operands are equal.

Returns:
true if the specified compare predicate is true when both operands are equal...

Definition at line 780 of file Instructions.h.

References llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_UGE, and llvm::CmpInst::ICMP_ULE.

bool llvm::ICmpInst::isTrueWhenEqual (  )  [inline]

Determine if the ICmpInst returns true when both operands are equal.

Returns:
true if the specified compare instruction is true when both operands are equal...

Definition at line 789 of file Instructions.h.

References getPredicate(), and llvm::ISD::isTrueWhenEqual().

ConstantRange ICmpInst::makeConstantRange ( Predicate  pred,
const APInt &  C 
) [static]

Make a ConstantRange for a relation with a constant value.

Initialize a set of values that all satisfy the predicate with C.

Initialize a set of values that all satisfy the condition with C.

Definition at line 2633 of file Instructions.cpp.

References llvm::APInt::getBitWidth(), llvm::APInt::getMinValue(), llvm::APInt::getSignedMinValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, and llvm_unreachable.

void llvm::ICmpInst::swapOperands (  )  [inline]

Swap operands and adjust predicate.

Exchange the two operands to this instruction in such a way that it does not modify the semantics of the instruction. The predicate value may be changed to retain the same result if the predicate is order dependent (e.g. ult).

Reimplemented from llvm::CmpInst.

Definition at line 802 of file Instructions.h.

References llvm::swap().

ICmpInst * ICmpInst::clone ( LLVMContext &  Context  )  const [virtual]

clone() - Create a copy of 'this' instruction that is identical in all ways except the following: The instruction has no parent The instruction has no name

Implements llvm::Instruction.

Definition at line 2882 of file Instructions.cpp.

References llvm::CmpInst::getPredicate(), ICmpInst(), and llvm::Value::SubclassOptionalData.

static bool llvm::ICmpInst::classof ( const ICmpInst *   )  [inline, static]

Definition at line 810 of file Instructions.h.

static bool llvm::ICmpInst::classof ( const Instruction *   )  [inline, static]

Methods for support type inquiry through isa, cast, and dyn_cast:.

Reimplemented from llvm::CmpInst.

Definition at line 811 of file Instructions.h.

References llvm::Instruction::getOpcode().

static bool llvm::ICmpInst::classof ( const Value *  V  )  [inline, static]

Reimplemented from llvm::CmpInst.

Definition at line 814 of file Instructions.h.


The documentation for this class was generated from the following files: