LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
llvm::CmpPredicate Class Reference

An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign information. More...

#include "llvm/IR/CmpPredicate.h"

Public Member Functions

 CmpPredicate ()
 Default constructor.
 
 CmpPredicate (CmpInst::Predicate Pred, bool HasSameSign=false)
 Constructed implictly with a either Predicate and samesign information, or just a Predicate, dropping samesign information.
 
 operator CmpInst::Predicate () const
 Implictly converts to the underlying Predicate, dropping samesign information.
 
bool hasSameSign () const
 Query samesign information, for optimizations.
 
bool operator== (CmpInst::Predicate P) const
 An operator== on the underlying Predicate.
 
bool operator!= (CmpInst::Predicate P) const
 
bool operator== (CmpPredicate) const =delete
 There is no operator== defined on CmpPredicate.
 
bool operator!= (CmpPredicate) const =delete
 

Static Public Member Functions

static std::optional< CmpPredicategetMatching (CmpPredicate A, CmpPredicate B)
 Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if they match.
 
static CmpPredicate get (const CmpInst *Cmp)
 Do a ICmpInst::getCmpPredicate() or CmpInst::getPredicate(), as appropriate.
 
static CmpPredicate getSwapped (CmpPredicate P)
 Get the swapped predicate of a CmpPredicate.
 
static CmpPredicate getSwapped (const CmpInst *Cmp)
 Get the swapped predicate of a CmpInst.
 

Detailed Description

An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign information.

Some functions in ICmpInst construct and return this type in place of a Predicate.

Definition at line 22 of file CmpPredicate.h.

Constructor & Destructor Documentation

◆ CmpPredicate() [1/2]

llvm::CmpPredicate::CmpPredicate ( )
inline

Default constructor.

Definition at line 28 of file CmpPredicate.h.

Referenced by getMatching().

◆ CmpPredicate() [2/2]

llvm::CmpPredicate::CmpPredicate ( CmpInst::Predicate  Pred,
bool  HasSameSign = false 
)
inline

Constructed implictly with a either Predicate and samesign information, or just a Predicate, dropping samesign information.

Definition at line 32 of file CmpPredicate.h.

References assert(), and llvm::CmpInst::isIntPredicate().

Member Function Documentation

◆ get()

CmpPredicate CmpPredicate::get ( const CmpInst Cmp)
static

◆ getMatching()

std::optional< CmpPredicate > CmpPredicate::getMatching ( CmpPredicate  A,
CmpPredicate  B 
)
static

Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if they match.

An alternative to operator==.

For example, samesign ult + samesign ult -> samesign ult samesign ult + ult -> ult samesign ult + slt -> slt ult + ult -> ult ult + slt -> std::nullopt

Definition at line 3922 of file Instructions.cpp.

References A, B, CmpPredicate(), and llvm::ICmpInst::getFlippedSignednessPredicate().

Referenced by isImpliedCondICmps(), and llvm::PatternMatch::SpecificCmpClass_match< LHS_t, RHS_t, Class, Commutable >::match().

◆ getSwapped() [1/2]

CmpPredicate CmpPredicate::getSwapped ( CmpPredicate  P)
static

◆ getSwapped() [2/2]

CmpPredicate CmpPredicate::getSwapped ( const CmpInst Cmp)
static

Get the swapped predicate of a CmpInst.

Definition at line 3945 of file Instructions.cpp.

References get(), and getSwapped().

◆ hasSameSign()

bool llvm::CmpPredicate::hasSameSign ( ) const
inline

Query samesign information, for optimizations.

Definition at line 42 of file CmpPredicate.h.

Referenced by llvm::ICmpInst::getInverseCmpPredicate(), and llvm::ICmpInst::getSwappedCmpPredicate().

◆ operator CmpInst::Predicate()

llvm::CmpPredicate::operator CmpInst::Predicate ( ) const
inline

Implictly converts to the underlying Predicate, dropping samesign information.

Definition at line 39 of file CmpPredicate.h.

◆ operator!=() [1/2]

bool llvm::CmpPredicate::operator!= ( CmpInst::Predicate  P) const
inline

Definition at line 58 of file CmpPredicate.h.

References P.

◆ operator!=() [2/2]

bool llvm::CmpPredicate::operator!= ( CmpPredicate  ) const
delete

◆ operator==() [1/2]

bool llvm::CmpPredicate::operator== ( CmpInst::Predicate  P) const
inline

An operator== on the underlying Predicate.

Definition at line 57 of file CmpPredicate.h.

References P.

◆ operator==() [2/2]

bool llvm::CmpPredicate::operator== ( CmpPredicate  ) const
delete

There is no operator== defined on CmpPredicate.

Use getMatching instead to get the canonicalized matching CmpPredicate.


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