LLVM API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions
llvm::ICmpInst Class Reference

Represent an integer comparison operator. More...

#include <Instructions.h>

Inheritance diagram for llvm::ICmpInst:
Inheritance graph
[legend]
Collaboration diagram for llvm::ICmpInst:
Collaboration graph
[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 (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
void swapOperands ()
 Swap operands and adjust predicate.

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 ConstantRange makeConstantRange (Predicate pred, const APInt &C)
 Make a ConstantRange for a relation with a constant value.
static bool classof (const Instruction *I)
 Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast:

Protected Member Functions

ICmpInstclone_impl () const override
 Clone an identical ICmpInst.

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 993 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:
InsertBeforeWhere to insert
predThe predicate to use for the comparison
LHSThe left-hand-side of the expression
RHSThe right-hand-side of the expression
NameStrName of the instruction

Definition at line 1011 of file Instructions.h.

Referenced by clone_impl().

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

Constructor with insert-at-end semantics.

Parameters:
InsertAtEndBlock to insert into.
predThe predicate to use for the comparison
LHSThe left-hand-side of the expression
RHSThe right-hand-side of the expression
NameStrName of the instruction

Definition at line 1026 of file Instructions.h.

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

Constructor with no-insertion semantics.

Parameters:
predThe predicate to use for the comparison
LHSThe left-hand-side of the expression
RHSThe right-hand-side of the expression
NameStrName of the instruction

Definition at line 1041 of file Instructions.h.


Member Function Documentation

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

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

Reimplemented from llvm::CmpInst.

Definition at line 1120 of file Instructions.h.

References llvm::Instruction::getOpcode().

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

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

Reimplemented from llvm::CmpInst.

Definition at line 1123 of file Instructions.h.

ICmpInst * ICmpInst::clone_impl ( ) const [override, protected, virtual]

Clone an identical ICmpInst.

Implements llvm::Instruction.

Definition at line 3591 of file Instructions.cpp.

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

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 1057 of file Instructions.h.

Referenced by computePointerICmp(), llvm::InstCombiner::FoldGEPICmp(), SimplifyICmpInst(), llvm::InstCombiner::visitICmpInst(), and llvm::InstCombiner::visitICmpInstWithInstAndIntCst().

Return the signed version of the predicate.

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

Definition at line 3187 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, llvm::CmpInst::ICMP_ULT, and llvm_unreachable.

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 1069 of file Instructions.h.

Referenced by SimplifyICmpInst(), llvm::InstCombiner::visitICmpInst(), llvm::InstCombiner::visitICmpInstWithCastAndCast(), and llvm::InstCombiner::visitICmpInstWithInstAndIntCst().

Return the unsigned version of the predicate.

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

Definition at line 3200 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, llvm::CmpInst::ICMP_ULT, and llvm_unreachable.

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::CmpInst.

Definition at line 1091 of file Instructions.h.

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

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

Reimplemented from llvm::CmpInst.

Definition at line 1085 of file Instructions.h.

Referenced by llvm::ConstantFoldCompareInstruction(), llvm::InstCombiner::FoldAndOfICmps(), foldLogOpOfMaskedICmps(), foldLogOpOfMaskedICmpsHelper(), llvm::InstCombiner::FoldOrOfICmps(), llvm::PredicatesFoldable(), SimplifyICmpInst(), and llvm::InstCombiner::visitICmpInst().

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

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

Definition at line 1095 of file Instructions.h.

Referenced by isSignTest().

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

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

Definition at line 1101 of file Instructions.h.

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 1114 of file Instructions.h.

References llvm::PPC::getSwappedPredicate(), and std::swap().

Referenced by llvm::InstCombiner::FoldAndOfICmps(), llvm::InstCombiner::FoldOrOfICmps(), and llvm::InstCombiner::visitICmpInst().


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