LLVM 24.0.0git
llvm::ConstraintSystem Class Reference

#include "llvm/Analysis/ConstraintSystem.h"

Classes

struct  Entry

Public Types

using RowTy = SmallVector<Entry, 8>
 A single constraint of the form 'c >= v1 * c1 + ... + vn * cn'.

Public Member Functions

 ConstraintSystem ()=default
 ConstraintSystem (ArrayRef< Value * > FunctionArgs)
 ConstraintSystem (const DenseMap< Value *, unsigned > &Value2Index)
bool addRow (ArrayRef< Entry > R, size_t NumVars)
DenseMap< Value *, unsigned > & getValue2Index ()
const DenseMap< Value *, unsigned > & getValue2Index () const
LLVM_ABI bool mayHaveSolution ()
 Returns true if there may be a solution for the constraints in the system.
LLVM_ABI std::pair< ConstraintSystem, RowTygetSubSystem (ArrayRef< Entry > R) const
 Build and return a sub-system of constraints connected (transitively) to query R, with variables compacted to a dense index range.
LLVM_ABI bool isConditionImplied (RowTy R) const
LLVM_ABI bool isConditionImpliedInSubSystem (ArrayRef< Entry > R) const
const RowTygetLastConstraint () const
void popLastConstraint ()
void popLastNVariables (unsigned N)
unsigned size () const
 Returns the number of rows in the constraint system.
LLVM_ABI void dump () const
 Print the constraints in the system.

Static Public Member Functions

static RowTy negate (RowTy R)
static RowTy negateOrEqual (RowTy R)
 Multiplies each coefficient in the given row by -1.
static RowTy toStrictLessThan (RowTy R)
 Converts the given row to form a strict less than inequality.

Detailed Description

Definition at line 23 of file ConstraintSystem.h.

Member Typedef Documentation

◆ RowTy

A single constraint of the form 'c >= v1 * c1 + ... + vn * cn'.

Definition at line 34 of file ConstraintSystem.h.

Constructor & Destructor Documentation

◆ ConstraintSystem() [1/3]

llvm::ConstraintSystem::ConstraintSystem ( )
default

Referenced by getSubSystem().

◆ ConstraintSystem() [2/3]

llvm::ConstraintSystem::ConstraintSystem ( ArrayRef< Value * > FunctionArgs)
inline

Definition at line 84 of file ConstraintSystem.h.

References llvm::ArrayRef< T >::size().

◆ ConstraintSystem() [3/3]

llvm::ConstraintSystem::ConstraintSystem ( const DenseMap< Value *, unsigned > & Value2Index)
inline

Definition at line 90 of file ConstraintSystem.h.

References size().

Member Function Documentation

◆ addRow()

bool llvm::ConstraintSystem::addRow ( ArrayRef< Entry > R,
size_t NumVars )
inline

Definition at line 93 of file ConstraintSystem.h.

References assert(), E(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by dumpConstraint().

◆ dump()

void ConstraintSystem::dump ( ) const

◆ getLastConstraint()

const RowTy & llvm::ConstraintSystem::getLastConstraint ( ) const
inline

Definition at line 161 of file ConstraintSystem.h.

References assert().

◆ getSubSystem()

std::pair< ConstraintSystem, ConstraintSystem::RowTy > ConstraintSystem::getSubSystem ( ArrayRef< Entry > R) const

Build and return a sub-system of constraints connected (transitively) to query R, with variables compacted to a dense index range.

Also translate R's entries to the sub-system.

Definition at line 221 of file ConstraintSystem.cpp.

References llvm::any_of(), assert(), Changed, ConstraintSystem(), llvm::SmallVectorImpl< T >::emplace_back(), and llvm::SmallBitVector::set_bits().

Referenced by isConditionImpliedInSubSystem().

◆ getValue2Index() [1/2]

DenseMap< Value *, unsigned > & llvm::ConstraintSystem::getValue2Index ( )
inline

Definition at line 110 of file ConstraintSystem.h.

◆ getValue2Index() [2/2]

const DenseMap< Value *, unsigned > & llvm::ConstraintSystem::getValue2Index ( ) const
inline

Definition at line 111 of file ConstraintSystem.h.

◆ isConditionImplied()

bool ConstraintSystem::isConditionImplied ( RowTy R) const

Definition at line 280 of file ConstraintSystem.cpp.

References negate().

◆ isConditionImpliedInSubSystem()

bool ConstraintSystem::isConditionImpliedInSubSystem ( ArrayRef< Entry > R) const

Definition at line 297 of file ConstraintSystem.cpp.

References getSubSystem().

◆ mayHaveSolution()

bool ConstraintSystem::mayHaveSolution ( )

Returns true if there may be a solution for the constraints in the system.

Definition at line 212 of file ConstraintSystem.cpp.

References llvm::dbgs(), dump(), and LLVM_DEBUG.

◆ negate()

RowTy llvm::ConstraintSystem::negate ( RowTy R)
inlinestatic

Definition at line 118 of file ConstraintSystem.h.

References llvm::AddOverflow(), assert(), and negateOrEqual().

Referenced by isConditionImplied().

◆ negateOrEqual()

RowTy llvm::ConstraintSystem::negateOrEqual ( RowTy R)
inlinestatic

Multiplies each coefficient in the given row by -1.

Returns an empty row on overflow. Does not modify the original row.

Parameters
RThe row of coefficients to be negated.

Definition at line 132 of file ConstraintSystem.h.

References E(), and llvm::MulOverflow().

Referenced by negate().

◆ popLastConstraint()

void llvm::ConstraintSystem::popLastConstraint ( )
inline

Definition at line 166 of file ConstraintSystem.h.

◆ popLastNVariables()

void llvm::ConstraintSystem::popLastNVariables ( unsigned N)
inline

Definition at line 167 of file ConstraintSystem.h.

References assert(), and N.

◆ size()

unsigned llvm::ConstraintSystem::size ( ) const
inline

Returns the number of rows in the constraint system.

Definition at line 173 of file ConstraintSystem.h.

Referenced by ConstraintSystem().

◆ toStrictLessThan()

RowTy llvm::ConstraintSystem::toStrictLessThan ( RowTy R)
inlinestatic

Converts the given row to form a strict less than inequality.

Returns an empty row on overflow. Does not modify the original row.

Parameters
RThe row of coefficients to be converted.

Definition at line 144 of file ConstraintSystem.h.

References assert(), and llvm::SubOverflow().


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