9#ifndef LLVM_ANALYSIS_CONSTRAINTSYSTEM_H
10#define LLVM_ANALYSIS_CONSTRAINTSYSTEM_H
28 Entry(int64_t Coefficient,
uint16_t Id)
29 : Coefficient(Coefficient), Id(Id) {}
32 static int64_t getConstPart(
const Entry &
E) {
41 if (Row.back().Id == Id)
42 return Row.back().Coefficient;
46 size_t NumVariables = 0;
58 bool eliminateUsingFM();
61 bool mayHaveSolutionImpl();
69 NumVariables += FunctionArgs.
size();
70 for (
auto *Arg : FunctionArgs) {
71 Value2Index.
insert({Arg, Value2Index.
size() + 1});
75 : NumVariables(Value2Index.
size()), Value2Index(Value2Index) {}
78 assert(Constraints.
empty() || R.size() == NumVariables);
90 if (Constraints.
empty())
91 NumVariables = R.size();
107 NumVariables = std::max(R.size(), NumVariables);
150 assert(!Constraints.
empty() &&
"Constraint system is empty");
152 for (
auto &Entry : Constraints.
back())
153 Result[Entry.Id] = Entry.Coefficient;
164 unsigned size()
const {
return Constraints.
size(); }
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
DenseMap< Value *, unsigned > & getValue2Index()
static SmallVector< int64_t, 8 > negate(SmallVector< int64_t, 8 > R)
LLVM_ABI bool mayHaveSolution()
Returns true if there may be a solution for the constraints in the system.
LLVM_ABI bool isConditionImplied(SmallVector< int64_t, 8 > R) const
unsigned size() const
Returns the number of rows in the constraint system.
ConstraintSystem(const DenseMap< Value *, unsigned > &Value2Index)
SmallVector< int64_t > getLastConstraint() const
static SmallVector< int64_t, 8 > toStrictLessThan(SmallVector< int64_t, 8 > R)
Converts the given vector to form a strict less than inequality.
bool addVariableRow(ArrayRef< int64_t > R)
void popLastNVariables(unsigned N)
static SmallVector< int64_t, 8 > negateOrEqual(SmallVector< int64_t, 8 > R)
Multiplies each coefficient in the given vector by -1.
const DenseMap< Value *, unsigned > & getValue2Index() const
bool addVariableRowFill(ArrayRef< int64_t > R)
LLVM_ABI void dump() const
Print the constraints in the system.
ConstraintSystem(ArrayRef< Value * > FunctionArgs)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
std::enable_if_t< std::is_signed_v< T >, T > MulOverflow(T X, T Y, T &Result)
Multiply two signed integers, computing the two's complement truncated result, returning true if an o...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
std::enable_if_t< std::is_signed_v< T >, T > AddOverflow(T X, T Y, T &Result)
Add two signed integers, computing the two's complement truncated result, returning true if overflow ...
std::enable_if_t< std::is_signed_v< T >, T > SubOverflow(T X, T Y, T &Result)
Subtract two signed integers, computing the two's complement truncated result, returning true if an o...