9#ifndef LLVM_ANALYSIS_CONSTRAINTSYSTEM_H
10#define LLVM_ANALYSIS_CONSTRAINTSYSTEM_H
38 if (R.empty() || R.back().Id != Id)
40 return R.back().Coefficient;
45 return !R.empty() && R.front().Id == 0;
51 return R.empty() || (R.size() == 1 && R.front().Id == 0);
57 return hasConstantEntry(R) ?
R.front().Coefficient : 0;
62 size_t NumVariables = 0;
71 DenseMap<Value *, unsigned> Value2Index;
74 bool eliminateUsingFM();
77 bool mayHaveSolutionImpl();
80 SmallVector<std::string> getVarNamesList()
const;
85 NumVariables += FunctionArgs.
size();
86 for (
auto *Arg : FunctionArgs) {
87 Value2Index.insert({Arg, Value2Index.size() + 1});
91 : NumVariables(Value2Index.
size()), Value2Index(Value2Index) {}
96 if (isConstantOnly(R))
99 assert(NumVars >= R.back().Id &&
"NumVars must cover all variables in R");
100 NumVariables = std::max(NumVars, NumVariables);
103 RowTy &NewRow = Constraints.emplace_back();
105 if (
E.Coefficient != 0)
119 assert(hasConstantEntry(R) &&
"row must have a constant entry");
122 if (
AddOverflow(R[0].Coefficient, int64_t(1), R[0].Coefficient))
145 assert(hasConstantEntry(R) &&
"row must have a constant entry");
147 if (
SubOverflow(R[0].Coefficient, int64_t(1), R[0].Coefficient))
155 LLVM_ABI std::pair<ConstraintSystem, RowTy>
162 assert(!Constraints.empty() &&
"Constraint system is empty");
163 return Constraints.back();
173 unsigned size()
const {
return Constraints.size(); }
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
DenseMap< Value *, unsigned > & getValue2Index()
LLVM_ABI bool isConditionImplied(RowTy R) const
bool addRow(ArrayRef< Entry > R, size_t NumVars)
LLVM_ABI bool mayHaveSolution()
Returns true if there may be a solution for the constraints in the system.
static RowTy negate(RowTy R)
const RowTy & getLastConstraint() const
unsigned size() const
Returns the number of rows in the constraint system.
LLVM_ABI std::pair< ConstraintSystem, RowTy > getSubSystem(ArrayRef< Entry > R) const
Build and return a sub-system of constraints connected (transitively) to query R, with variables comp...
ConstraintSystem(const DenseMap< Value *, unsigned > &Value2Index)
static RowTy toStrictLessThan(RowTy R)
Converts the given row to form a strict less than inequality.
LLVM_ABI bool isConditionImpliedInSubSystem(ArrayRef< Entry > R) const
void popLastNVariables(unsigned N)
ConstraintSystem()=default
const DenseMap< Value *, unsigned > & getValue2Index() const
SmallVector< Entry, 8 > RowTy
A single constraint of the form 'c >= v1 * c1 + ... + vn * cn'.
static RowTy negateOrEqual(RowTy R)
Multiplies each coefficient in the given row by -1.
LLVM_ABI void dump() const
Print the constraints in the system.
ConstraintSystem(ArrayRef< Value * > FunctionArgs)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
constexpr std::enable_if_t< std::is_signed_v< T >, std::pair< T, bool > > AddOverflow(T X, T Y)
Add two signed integers, computing the two's complement truncated result, returning a pair {result,...
constexpr std::enable_if_t< std::is_signed_v< T >, std::pair< T, bool > > SubOverflow(T X, T Y)
Subtract two signed integers, computing the two's complement truncated result, returning a pair {resu...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr std::enable_if_t< std::is_signed_v< T >, std::pair< T, bool > > MulOverflow(T X, T Y)
Multiply two signed integers, computing the two's complement truncated result, returning a pair {resu...
Entry(int64_t Coefficient, uint16_t Id)