class CmpInst

Declaration

class CmpInst : public Instruction { /* full declaration omitted */ };

Declared at: llvm/include/llvm/IR/InstrTypes.h:722

Inherits from: Instruction

Member Variables

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 29
public static MaximumAlignment = 1U << MaxAlignmentExponent

Method Overview

  • protected CmpInst(llvm::Type * ty, Instruction::OtherOps op, llvm::CmpInst::Predicate pred, llvm::Value * LHS, llvm::Value * RHS, const llvm::Twine & Name, llvm::BasicBlock * InsertAtEnd)
  • protected CmpInst(llvm::Type * ty, Instruction::OtherOps op, llvm::CmpInst::Predicate pred, llvm::Value * LHS, llvm::Value * RHS, const llvm::Twine & Name = "", llvm::Instruction * InsertBefore = nullptr, llvm::Instruction * FlagsSource = nullptr)
  • public static llvm::CmpInst * Create(llvm::Instruction::OtherOps Op, llvm::CmpInst::Predicate predicate, llvm::Value * S1, llvm::Value * S2, const llvm::Twine & Name = "", llvm::Instruction * InsertBefore = nullptr)
  • public static llvm::CmpInst * Create(llvm::Instruction::OtherOps Op, llvm::CmpInst::Predicate predicate, llvm::Value * S1, llvm::Value * S2, const llvm::Twine & Name, llvm::BasicBlock * InsertAtEnd)
  • public static bool classof(const llvm::Instruction * I)
  • public static bool classof(const llvm::Value * V)
  • public llvm::CmpInst::Predicate getFlippedStrictnessPredicate() const
  • public static llvm::CmpInst::Predicate getFlippedStrictnessPredicate(llvm::CmpInst::Predicate pred)
  • public llvm::CmpInst::Predicate getInversePredicate() const
  • public static llvm::CmpInst::Predicate getInversePredicate(llvm::CmpInst::Predicate pred)
  • public llvm::CmpInst::Predicate getNonStrictPredicate() const
  • public static llvm::CmpInst::Predicate getNonStrictPredicate(llvm::CmpInst::Predicate pred)
  • public llvm::Instruction::OtherOps getOpcode() const
  • public llvm::CmpInst::Predicate getPredicate() const
  • public static llvm::StringRef getPredicateName(llvm::CmpInst::Predicate P)
  • public llvm::CmpInst::Predicate getSignedPredicate()
  • public static llvm::CmpInst::Predicate getSignedPredicate(llvm::CmpInst::Predicate pred)
  • public llvm::CmpInst::Predicate getSwappedPredicate() const
  • public static llvm::CmpInst::Predicate getSwappedPredicate(llvm::CmpInst::Predicate pred)
  • public bool isCommutative() const
  • public bool isEquality() const
  • public static bool isFPPredicate(llvm::CmpInst::Predicate P)
  • public bool isFPPredicate() const
  • public bool isFalseWhenEqual() const
  • public static bool isFalseWhenEqual(llvm::CmpInst::Predicate predicate)
  • public static bool isImpliedFalseByMatchingCmp(llvm::CmpInst::Predicate Pred1, llvm::CmpInst::Predicate Pred2)
  • public static bool isImpliedTrueByMatchingCmp(llvm::CmpInst::Predicate Pred1, llvm::CmpInst::Predicate Pred2)
  • public bool isIntPredicate() const
  • public static bool isIntPredicate(llvm::CmpInst::Predicate P)
  • public static bool isOrdered(llvm::CmpInst::Predicate predicate)
  • public bool isSigned() const
  • public static bool isSigned(llvm::CmpInst::Predicate predicate)
  • public bool isTrueWhenEqual() const
  • public static bool isTrueWhenEqual(llvm::CmpInst::Predicate predicate)
  • public static bool isUnordered(llvm::CmpInst::Predicate predicate)
  • public bool isUnsigned() const
  • public static bool isUnsigned(llvm::CmpInst::Predicate predicate)
  • public static llvm::Type * makeCmpResultType(llvm::Type * opnd_type)
  • public void setPredicate(llvm::CmpInst::Predicate P)
  • public void swapOperands()

Inherited from Instruction:

Inherited from User:

Inherited from Value:

Methods

CmpInst(llvm::Type* ty,
        Instruction::OtherOps op,
        llvm::CmpInst::Predicate pred,
        llvm::Value* LHS,
        llvm::Value* RHS,
        const llvm::Twine& Name,
        llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/InstrTypes.h:774

Parameters

llvm::Type* ty
Instruction::OtherOps op
llvm::CmpInst::Predicate pred
llvm::Value* LHS
llvm::Value* RHS
const llvm::Twine& Name
llvm::BasicBlock* InsertAtEnd

CmpInst(llvm::Type* ty,
        Instruction::OtherOps op,
        llvm::CmpInst::Predicate pred,
        llvm::Value* LHS,
        llvm::Value* RHS,
        const llvm::Twine& Name = "",
        llvm::Instruction* InsertBefore = nullptr,
        llvm::Instruction* FlagsSource = nullptr)

Declared at: llvm/include/llvm/IR/InstrTypes.h:769

Parameters

llvm::Type* ty
Instruction::OtherOps op
llvm::CmpInst::Predicate pred
llvm::Value* LHS
llvm::Value* RHS
const llvm::Twine& Name = ""
llvm::Instruction* InsertBefore = nullptr
llvm::Instruction* FlagsSource = nullptr

static llvm::CmpInst* Create(
    llvm::Instruction::OtherOps Op,
    llvm::CmpInst::Predicate predicate,
    llvm::Value* S1,
    llvm::Value* S2,
    const llvm::Twine& Name = "",
    llvm::Instruction* InsertBefore = nullptr)

Description

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. Create a CmpInst

Declared at: llvm/include/llvm/IR/InstrTypes.h:789

Parameters

llvm::Instruction::OtherOps Op
llvm::CmpInst::Predicate predicate
llvm::Value* S1
llvm::Value* S2
const llvm::Twine& Name = ""
llvm::Instruction* InsertBefore = nullptr

static llvm::CmpInst* Create(
    llvm::Instruction::OtherOps Op,
    llvm::CmpInst::Predicate predicate,
    llvm::Value* S1,
    llvm::Value* S2,
    const llvm::Twine& Name,
    llvm::BasicBlock* InsertAtEnd)

Description

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. Create a CmpInst

Declared at: llvm/include/llvm/IR/InstrTypes.h:798

Parameters

llvm::Instruction::OtherOps Op
llvm::CmpInst::Predicate predicate
llvm::Value* S1
llvm::Value* S2
const llvm::Twine& Name
llvm::BasicBlock* InsertAtEnd

static bool classof(const llvm::Instruction* I)

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:966

Parameters

const llvm::Instruction* I

static bool classof(const llvm::Value* V)

Declared at: llvm/include/llvm/IR/InstrTypes.h:970

Parameters

const llvm::Value* V

llvm::CmpInst::Predicate
getFlippedStrictnessPredicate() const

Description

For predicate of kind "is X or equal to 0" returns the predicate "is X". For predicate of kind "is X" returns the predicate "is X or equal to 0". does not support other kind of predicates.

Declared at: llvm/include/llvm/IR/InstrTypes.h:862

Returns

the predicate that does not contains is equal to zero if it had and vice versa. Return the flipped strictness of predicate

static llvm::CmpInst::Predicate
getFlippedStrictnessPredicate(
    llvm::CmpInst::Predicate pred)

Description

This is a static version that you can use without an instruction available. Return the flipped strictness of predicate

Declared at: llvm/include/llvm/IR/InstrTypes.h:869

Parameters

llvm::CmpInst::Predicate pred

llvm::CmpInst::Predicate getInversePredicate()
    const

Description

For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.

Declared at: llvm/include/llvm/IR/InstrTypes.h:831

Returns

the inverse predicate for the instruction's current predicate. Return the inverse of the instruction's predicate.

static llvm::CmpInst::Predicate
getInversePredicate(llvm::CmpInst::Predicate pred)

Description

For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.

Declared at: llvm/include/llvm/IR/InstrTypes.h:839

Parameters

llvm::CmpInst::Predicate pred

Returns

the inverse predicate for predicate provided in \p pred. Return the inverse of a given predicate

llvm::CmpInst::Predicate getNonStrictPredicate()
    const

Description

For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE. Returns the non-strict version of strict comparisons.

Declared at: llvm/include/llvm/IR/InstrTypes.h:873

static llvm::CmpInst::Predicate
getNonStrictPredicate(
    llvm::CmpInst::Predicate pred)

Description

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

Declared at: llvm/include/llvm/IR/InstrTypes.h:882

Parameters

llvm::CmpInst::Predicate pred

Returns

the non-strict version of comparison provided in \p pred. If \p pred is not a strict comparison predicate, returns \p pred. Returns the non-strict version of strict comparisons.

llvm::Instruction::OtherOps getOpcode() const

Description

Get the opcode casted to the right type

Declared at: llvm/include/llvm/IR/InstrTypes.h:802

llvm::CmpInst::Predicate getPredicate() const

Description

Return the predicate for this instruction.

Declared at: llvm/include/llvm/IR/InstrTypes.h:807

static llvm::StringRef getPredicateName(
    llvm::CmpInst::Predicate P)

Declared at: llvm/include/llvm/IR/InstrTypes.h:822

Parameters

llvm::CmpInst::Predicate P

llvm::CmpInst::Predicate getSignedPredicate()

Description

For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert

Declared at: llvm/include/llvm/IR/InstrTypes.h:921

Returns

the signed version of the predicate for this instruction (which has to be an unsigned predicate). return the signed version of a predicate

static llvm::CmpInst::Predicate
getSignedPredicate(llvm::CmpInst::Predicate pred)

Description

For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert

Declared at: llvm/include/llvm/IR/InstrTypes.h:915

Parameters

llvm::CmpInst::Predicate pred

Returns

the signed version of the unsigned predicate pred. return the signed version of a predicate

llvm::CmpInst::Predicate getSwappedPredicate()
    const

Description

For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.

Declared at: llvm/include/llvm/IR/InstrTypes.h:847

Returns

the predicate that would be the result of exchanging the two operands of the CmpInst instruction without changing the result produced. Return the predicate as if the operands were swapped

static llvm::CmpInst::Predicate
getSwappedPredicate(llvm::CmpInst::Predicate pred)

Description

This is a static version that you can use without an instruction available. Return the predicate as if the operands were swapped.

Declared at: llvm/include/llvm/IR/InstrTypes.h:854

Parameters

llvm::CmpInst::Predicate pred

bool isCommutative() const

Description

This is just a convenience that dispatches to the subclasses. Determine if this CmpInst is commutative.

Declared at: llvm/include/llvm/IR/InstrTypes.h:894

bool isEquality() const

Description

This is just a convenience that dispatches to the subclasses. Determine if this is an equals/not equals predicate.

Declared at: llvm/include/llvm/IR/InstrTypes.h:898

static bool isFPPredicate(
    llvm::CmpInst::Predicate P)

Declared at: llvm/include/llvm/IR/InstrTypes.h:814

Parameters

llvm::CmpInst::Predicate P

bool isFPPredicate() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:824

bool isFalseWhenEqual() const

Description

This is just a convenience. Determine if this is false when both operands are the same.

Declared at: llvm/include/llvm/IR/InstrTypes.h:933

static bool isFalseWhenEqual(
    llvm::CmpInst::Predicate predicate)

Description

Determine if the predicate is false when comparing a value with itself.

Declared at: llvm/include/llvm/IR/InstrTypes.h:955

Parameters

llvm::CmpInst::Predicate predicate

static bool isImpliedFalseByMatchingCmp(
    llvm::CmpInst::Predicate Pred1,
    llvm::CmpInst::Predicate Pred2)

Description

Determine if Pred1 implies Pred2 is false when two compares have matching operands.

Declared at: llvm/include/llvm/IR/InstrTypes.h:963

Parameters

llvm::CmpInst::Predicate Pred1
llvm::CmpInst::Predicate Pred2

static bool isImpliedTrueByMatchingCmp(
    llvm::CmpInst::Predicate Pred1,
    llvm::CmpInst::Predicate Pred2)

Description

Determine if Pred1 implies Pred2 is true when two compares have matching operands.

Declared at: llvm/include/llvm/IR/InstrTypes.h:959

Parameters

llvm::CmpInst::Predicate Pred1
llvm::CmpInst::Predicate Pred2

bool isIntPredicate() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:825

static bool isIntPredicate(
    llvm::CmpInst::Predicate P)

Declared at: llvm/include/llvm/IR/InstrTypes.h:818

Parameters

llvm::CmpInst::Predicate P

static bool isOrdered(
    llvm::CmpInst::Predicate predicate)

Description

Determine if the predicate is an ordered operation.

Declared at: llvm/include/llvm/IR/InstrTypes.h:946

Parameters

llvm::CmpInst::Predicate predicate

bool isSigned() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:902

Returns

true if the comparison is signed, false otherwise. Determine if this instruction is using a signed comparison.

static bool isSigned(
    llvm::CmpInst::Predicate predicate)

Declared at: llvm/include/llvm/IR/InstrTypes.h:943

Parameters

llvm::CmpInst::Predicate predicate

Returns

true if the predicate is signed, false otherwise. Determine if the predicate is an signed operation.

bool isTrueWhenEqual() const

Description

This is just a convenience. Determine if this is true when both operands are the same.

Declared at: llvm/include/llvm/IR/InstrTypes.h:927

static bool isTrueWhenEqual(
    llvm::CmpInst::Predicate predicate)

Description

Determine if the predicate is true when comparing a value with itself.

Declared at: llvm/include/llvm/IR/InstrTypes.h:952

Parameters

llvm::CmpInst::Predicate predicate

static bool isUnordered(
    llvm::CmpInst::Predicate predicate)

Description

Determine if the predicate is an unordered operation.

Declared at: llvm/include/llvm/IR/InstrTypes.h:949

Parameters

llvm::CmpInst::Predicate predicate

bool isUnsigned() const

Declared at: llvm/include/llvm/IR/InstrTypes.h:908

Returns

true if the comparison is unsigned, false otherwise. Determine if this instruction is using an unsigned comparison.

static bool isUnsigned(
    llvm::CmpInst::Predicate predicate)

Declared at: llvm/include/llvm/IR/InstrTypes.h:939

Parameters

llvm::CmpInst::Predicate predicate

Returns

true if the predicate is unsigned, false otherwise. Determine if the predicate is an unsigned operation.

static llvm::Type* makeCmpResultType(
    llvm::Type* opnd_type)

Description

Create a result type for fcmp/icmp

Declared at: llvm/include/llvm/IR/InstrTypes.h:975

Parameters

llvm::Type* opnd_type

void setPredicate(llvm::CmpInst::Predicate P)

Description

Set the predicate for this instruction to the specified value.

Declared at: llvm/include/llvm/IR/InstrTypes.h:812

Parameters

llvm::CmpInst::Predicate P

void swapOperands()

Description

This is just a convenience that dispatches to the subclasses. Swap the operands and adjust predicate accordingly to retain the same comparison.

Declared at: llvm/include/llvm/IR/InstrTypes.h:890