MLIR
17.0.0git
|
PresburgerSpace is the space of all possible values of a tuple of integer valued variables/variables. More...
#include "mlir/Analysis/Presburger/PresburgerSpace.h"
Public Member Functions | |
PresburgerSpace | getDomainSpace () const |
Get the domain/range space of this space. More... | |
PresburgerSpace | getRangeSpace () const |
PresburgerSpace | getSpaceWithoutLocals () const |
Get the space without local variables. More... | |
unsigned | getNumDomainVars () const |
unsigned | getNumRangeVars () const |
unsigned | getNumSetDimVars () const |
unsigned | getNumSymbolVars () const |
unsigned | getNumLocalVars () const |
unsigned | getNumDimVars () const |
unsigned | getNumDimAndSymbolVars () const |
unsigned | getNumVars () const |
unsigned | getNumVarKind (VarKind kind) const |
Get the number of vars of the specified kind. More... | |
unsigned | getVarKindOffset (VarKind kind) const |
Return the index at which the specified kind of var starts. More... | |
unsigned | getVarKindEnd (VarKind kind) const |
Return the index at Which the specified kind of var ends. More... | |
unsigned | getVarKindOverlap (VarKind kind, unsigned varStart, unsigned varLimit) const |
Get the number of elements of the specified kind in the range [varStart, varLimit). More... | |
VarKind | getVarKindAt (unsigned pos) const |
Return the VarKind of the var at the specified position. More... | |
unsigned | insertVar (VarKind kind, unsigned pos, unsigned num=1) |
Insert num variables of the specified kind at position pos . More... | |
void | removeVarRange (VarKind kind, unsigned varStart, unsigned varLimit) |
Removes variables of the specified kind in the column range [varStart, varLimit). More... | |
void | swapVar (VarKind kindA, VarKind kindB, unsigned posA, unsigned posB) |
Swaps the posA^th variable of kindA and posB^th variable of kindB. More... | |
bool | isCompatible (const PresburgerSpace &other) const |
Returns true if both the spaces are compatible i.e. More... | |
bool | isEqual (const PresburgerSpace &other) const |
Returns true if both the spaces are equal including local variables i.e. More... | |
void | setVarSymbolSeperation (unsigned newSymbolCount) |
Changes the partition between dimensions and symbols. More... | |
void | print (llvm::raw_ostream &os) const |
void | dump () const |
template<typename T > | |
void | setId (VarKind kind, unsigned i, T id) |
Set the identifier for i^th variable to id . More... | |
template<typename T > | |
T | getId (VarKind kind, unsigned i) const |
Get the identifier for i^th variable casted to type T . More... | |
bool | hasId (VarKind kind, unsigned i) const |
Check if the i^th variable of the specified kind has a non-null identifier. More... | |
bool | isAligned (const PresburgerSpace &other) const |
Check if the spaces are compatible, as well as have the same identifiers for each variable. More... | |
bool | isAligned (const PresburgerSpace &other, VarKind kind) const |
Check if the number of variables of the specified kind match, and have same identifiers with the other space. More... | |
template<typename T > | |
unsigned | findId (VarKind kind, T id) const |
Find the variable of the specified kind with identifier id . More... | |
bool | isUsingIds () const |
Returns if identifiers are being used. More... | |
template<typename T > | |
void | resetIds () |
Reset the stored identifiers in the space. More... | |
void | disableIds () |
Disable identifiers being stored in space. More... | |
Static Public Member Functions | |
static PresburgerSpace | getRelationSpace (unsigned numDomain=0, unsigned numRange=0, unsigned numSymbols=0, unsigned numLocals=0) |
static PresburgerSpace | getSetSpace (unsigned numDims=0, unsigned numSymbols=0, unsigned numLocals=0) |
Static Public Attributes | |
static const unsigned | kIdNotFound = UINT_MAX |
Protected Member Functions | |
PresburgerSpace (unsigned numDomain=0, unsigned numRange=0, unsigned numSymbols=0, unsigned numLocals=0) | |
void *& | atId (VarKind kind, unsigned i) |
void * | atId (VarKind kind, unsigned i) const |
PresburgerSpace is the space of all possible values of a tuple of integer valued variables/variables.
Each variable has one of the three types:
Dimension: Ordinary variables over which the space is represented.
Symbol: Symbol variables correspond to fixed but unknown values. Mathematically, a space with symbolic variables is like a family of spaces indexed by the symbolic variables.
Local: Local variables correspond to existentially quantified variables. For example, consider the space: (x, exists q)
where x is a dimension variable and q is a local variable. Let us put the constraints: 1 <= x <= 7, x = 2q
on this space to get the set: (x) : (exists q : q <= x <= 7, x = 2q)
. An assignment to symbolic and dimension variables is valid if there exists some assignment to the local variable q
satisfying these constraints. For this example, the set is equivalent to {2, 4, 6}. Mathematically, existential quantification can be thought of as the result of projection. In this example, q
is existentially quantified. This can be thought of as the result of projecting out q
from the previous example, i.e. we obtained {2, 4, 6} by projecting out the second dimension from {(2, 1), (4, 2), (6, 2)}.
Dimension variables are further divided into Domain and Range variables to support building relations.
Variables are stored in the following order: [Domain, Range, Symbols, Locals]
A space with no distinction between types of dimension variables can be implemented as a space with zero domain. VarKind::SetDim should be used to refer to dimensions in such spaces.
Compatibility of two spaces implies that number of variables of each kind other than Locals are equal. Equality of two spaces implies that number of variables of each kind are equal.
PresburgerSpace optionally also supports attaching some information to each variable in space, called "identifier" of that variable. resetIds<IdType>
is used to enable/reset these identifiers. All identifiers must be of the same type, IdType
. IdType
must have a llvm::PointerLikeTypeTraits
specialization available and should be supported via mlir::TypeID
.
These identifiers can be used to check if two variables in two different spaces are actually same variable.
Definition at line 77 of file PresburgerSpace.h.
|
inlineprotected |
Definition at line 238 of file PresburgerSpace.h.
Referenced by getRelationSpace(), and getSetSpace().
|
inlineprotected |
Definition at line 243 of file PresburgerSpace.h.
Referenced by swapVar().
|
inlineprotected |
Definition at line 250 of file PresburgerSpace.h.
|
inline |
Disable identifiers being stored in space.
Definition at line 232 of file PresburgerSpace.h.
void PresburgerSpace::dump | ( | ) | const |
Definition at line 213 of file PresburgerSpace.cpp.
References print().
|
inline |
Find the variable of the specified kind with identifier id
.
Returns PresburgerSpace::kIdNotFound if identifier is not found.
Definition at line 206 of file PresburgerSpace.h.
PresburgerSpace PresburgerSpace::getDomainSpace | ( | ) | const |
Get the domain/range space of this space.
The returned space is a set space.
Definition at line 16 of file PresburgerSpace.cpp.
References getSetSpace().
Referenced by mlir::presburger::MultiAffineFunction::getDomainSpace(), mlir::presburger::PWMAFunction::getDomainSpace(), and mlir::presburger::PWMAFunction::getOutputSpace().
|
inline |
Get the identifier for i^th
variable casted to type T
.
T
here should match the type used to enable identifiers.
Definition at line 183 of file PresburgerSpace.h.
|
inline |
Definition at line 108 of file PresburgerSpace.h.
Referenced by mlir::presburger::IntegerRelation::getNumDimAndSymbolVars(), resetIds(), and setVarSymbolSeperation().
|
inline |
Definition at line 107 of file PresburgerSpace.h.
Referenced by mlir::presburger::IntegerRelation::getNumDimVars().
|
inline |
Definition at line 101 of file PresburgerSpace.h.
Referenced by mlir::presburger::MultiAffineFunction::getAsRelation(), mlir::presburger::IntegerRelation::getNumDomainVars(), mlir::presburger::PresburgerRelation::getNumDomainVars(), mlir::presburger::MultiAffineFunction::getNumDomainVars(), mlir::presburger::PWMAFunction::getNumDomainVars(), mlir::presburger::IntegerRelation::getSpaceWithoutLocals(), mlir::presburger::IntegerPolyhedron::IntegerPolyhedron(), isCompatible(), mlir::presburger::PresburgerSet::PresburgerSet(), and print().
|
inline |
Definition at line 105 of file PresburgerSpace.h.
Referenced by mlir::presburger::MultiAffineFunction::getAsRelation(), mlir::presburger::MultiAffineFunction::getLexSet(), mlir::presburger::MultiAffineFunction::getNumDivs(), mlir::presburger::IntegerRelation::getNumLocalVars(), mlir::presburger::PresburgerRelation::getNumLocalVars(), getSetDifference(), isEqual(), mlir::presburger::PresburgerRelation::PresburgerRelation(), mlir::presburger::PresburgerSet::PresburgerSet(), print(), mlir::presburger::PWMAFunction::PWMAFunction(), mlir::presburger::PresburgerRelation::setSpace(), and mlir::presburger::IntegerRelation::setSpaceExceptLocals().
|
inline |
Definition at line 102 of file PresburgerSpace.h.
Referenced by mlir::presburger::MultiAffineFunction::getNumOutputs(), mlir::presburger::PWMAFunction::getNumOutputs(), mlir::presburger::IntegerRelation::getNumRangeVars(), mlir::presburger::PresburgerRelation::getNumRangeVars(), mlir::presburger::IntegerRelation::getSpaceWithoutLocals(), isCompatible(), and print().
|
inline |
Definition at line 103 of file PresburgerSpace.h.
|
inline |
Definition at line 104 of file PresburgerSpace.h.
Referenced by mlir::presburger::MultiAffineFunction::getAsRelation(), mlir::presburger::IntegerRelation::getNumSymbolVars(), mlir::presburger::PresburgerRelation::getNumSymbolVars(), mlir::presburger::MultiAffineFunction::getNumSymbolVars(), mlir::presburger::PWMAFunction::getNumSymbolVars(), mlir::presburger::IntegerRelation::getSpaceWithoutLocals(), isCompatible(), and print().
unsigned PresburgerSpace::getNumVarKind | ( | VarKind | kind | ) | const |
Get the number of vars of the specified kind.
Definition at line 31 of file PresburgerSpace.cpp.
|
inline |
Definition at line 111 of file PresburgerSpace.h.
Referenced by mlir::presburger::MultiAffineFunction::getLexSet(), mlir::presburger::IntegerRelation::getNumCols(), mlir::presburger::IntegerRelation::getNumVars(), mlir::presburger::PresburgerRelation::getNumVars(), getVarKindAt(), mlir::presburger::IntegerRelation::IntegerRelation(), mlir::presburger::IntegerRelation::setSpace(), and mlir::presburger::IntegerRelation::setSpaceExceptLocals().
PresburgerSpace PresburgerSpace::getRangeSpace | ( | ) | const |
Definition at line 21 of file PresburgerSpace.cpp.
References getSetSpace().
Referenced by mlir::presburger::MultiAffineFunction::getOutputSpace().
|
inlinestatic |
Definition at line 79 of file PresburgerSpace.h.
References PresburgerSpace().
Referenced by mlir::presburger::SymbolicLexSimplex::computeSymbolicIntegerLexMin(), mlir::presburger::MultiAffineFunction::getAsRelation(), mlir::presburger::IntegerRelation::getSpaceWithoutLocals(), and mlir::presburger::IntegerRelation::unionBoundingBox().
|
inlinestatic |
Definition at line 86 of file PresburgerSpace.h.
References PresburgerSpace().
Referenced by mlir::presburger::IntegerRelation::computeReprWithOnlyDivLocals(), mlir::presburger::IntegerRelation::findSymbolicIntegerLexMin(), getDomainSpace(), and getRangeSpace().
PresburgerSpace PresburgerSpace::getSpaceWithoutLocals | ( | ) | const |
Get the space without local variables.
Definition at line 25 of file PresburgerSpace.cpp.
References mlir::presburger::Local, and removeVarRange().
Referenced by mlir::presburger::MultiAffineFunction::getLexSet().
VarKind PresburgerSpace::getVarKindAt | ( | unsigned | pos | ) | const |
Return the VarKind of the var at the specified position.
Definition at line 74 of file PresburgerSpace.cpp.
References mlir::presburger::Domain, getNumVars(), getVarKindEnd(), mlir::presburger::Local, mlir::presburger::Range, and mlir::presburger::Symbol.
Referenced by mlir::presburger::IntegerRelation::fourierMotzkinEliminate(), and mlir::presburger::IntegerRelation::getVarKindAt().
unsigned PresburgerSpace::getVarKindEnd | ( | VarKind | kind | ) | const |
Return the index at Which the specified kind of var ends.
Definition at line 55 of file PresburgerSpace.cpp.
Referenced by getVarKindAt().
unsigned PresburgerSpace::getVarKindOffset | ( | VarKind | kind | ) | const |
Return the index at which the specified kind of var starts.
Definition at line 43 of file PresburgerSpace.cpp.
Referenced by mlir::presburger::IntegerRelation::fourierMotzkinEliminate().
unsigned PresburgerSpace::getVarKindOverlap | ( | VarKind | kind, |
unsigned | varStart, | ||
unsigned | varLimit | ||
) | const |
Get the number of elements of the specified kind in the range [varStart, varLimit).
Definition at line 59 of file PresburgerSpace.cpp.
|
inline |
Check if the i^th variable of the specified kind has a non-null identifier.
Definition at line 192 of file PresburgerSpace.h.
unsigned PresburgerSpace::insertVar | ( | VarKind | kind, |
unsigned | pos, | ||
unsigned | num = 1 |
||
) |
Insert num
variables of the specified kind at position pos
.
Positions are relative to the kind of variable. Return the absolute column position (i.e., not relative to the kind of variable) of the first added variable.
If identifiers are being used, the newly added variables have no identifiers.
Definition at line 87 of file PresburgerSpace.cpp.
Referenced by mlir::presburger::MultiAffineFunction::mergeDivs(), and mlir::presburger::IntegerRelation::setSpaceExceptLocals().
bool PresburgerSpace::isAligned | ( | const PresburgerSpace & | other | ) | const |
Check if the spaces are compatible, as well as have the same identifiers for each variable.
Definition at line 165 of file PresburgerSpace.cpp.
References isCompatible(), and isUsingIds().
bool PresburgerSpace::isAligned | ( | const PresburgerSpace & | other, |
VarKind | kind | ||
) | const |
Check if the number of variables of the specified kind match, and have same identifiers with the other space.
Definition at line 172 of file PresburgerSpace.cpp.
bool PresburgerSpace::isCompatible | ( | const PresburgerSpace & | other | ) | const |
Returns true if both the spaces are compatible i.e.
if both spaces have the same number of variables of each kind (excluding locals).
Definition at line 155 of file PresburgerSpace.cpp.
References getNumDomainVars(), getNumRangeVars(), and getNumSymbolVars().
Referenced by getSetDifference(), mlir::presburger::PresburgerRelation::intersect(), isAligned(), mlir::presburger::PWMAFunction::Piece::isConsistent(), mlir::presburger::IntegerRelation::isEqual(), mlir::presburger::MultiAffineFunction::isEqual(), mlir::presburger::PresburgerRelation::isEqual(), isEqual(), mlir::presburger::PWMAFunction::isEqual(), mlir::presburger::IntegerRelation::isSubsetOf(), mlir::presburger::MultiAffineFunction::mergeDivs(), mlir::presburger::mergeLocalVars(), mlir::presburger::MultiAffineFunction::subtract(), mlir::presburger::PresburgerRelation::subtract(), mlir::presburger::PresburgerRelation::unionInPlace(), and mlir::presburger::PresburgerRelation::unionSet().
bool PresburgerSpace::isEqual | ( | const PresburgerSpace & | other | ) | const |
Returns true if both the spaces are equal including local variables i.e.
if both spaces have the same number of variables of each kind (including locals).
Definition at line 161 of file PresburgerSpace.cpp.
References getNumLocalVars(), and isCompatible().
Referenced by mlir::presburger::IntegerRelation::append(), and mlir::presburger::IntegerRelation::unionBoundingBox().
|
inline |
Returns if identifiers are being used.
Definition at line 216 of file PresburgerSpace.h.
Referenced by isAligned().
void PresburgerSpace::print | ( | llvm::raw_ostream & | os | ) | const |
Definition at line 195 of file PresburgerSpace.cpp.
References getNumDomainVars(), getNumLocalVars(), getNumRangeVars(), and getNumSymbolVars().
Referenced by dump(), mlir::presburger::MultiAffineFunction::print(), mlir::presburger::PWMAFunction::print(), and mlir::presburger::IntegerRelation::printSpace().
void PresburgerSpace::removeVarRange | ( | VarKind | kind, |
unsigned | varStart, | ||
unsigned | varLimit | ||
) |
Removes variables of the specified kind in the column range [varStart, varLimit).
The range is relative to the kind of variable.
Definition at line 109 of file PresburgerSpace.cpp.
Referenced by mlir::presburger::IntegerRelation::computeReprWithOnlyDivLocals(), mlir::presburger::IntegerRelation::fourierMotzkinEliminate(), getSpaceWithoutLocals(), mlir::presburger::MultiAffineFunction::mergeDivs(), mlir::presburger::MultiAffineFunction::removeOutputs(), and mlir::presburger::PWMAFunction::removeOutputs().
|
inline |
Reset the stored identifiers in the space.
Enables usingIds
if it was false
before.
Definition at line 221 of file PresburgerSpace.h.
References getNumDimAndSymbolVars().
|
inline |
Set the identifier for i^th
variable to id
.
T
here should match the type used to enable identifiers.
Definition at line 173 of file PresburgerSpace.h.
void PresburgerSpace::setVarSymbolSeperation | ( | unsigned | newSymbolCount | ) |
Changes the partition between dimensions and symbols.
Depending on the new symbol count, either a chunk of dimensional variables immediately before the split become symbols, or some of the symbols immediately after the split become dimensions.
Definition at line 186 of file PresburgerSpace.cpp.
References getNumDimAndSymbolVars().
Referenced by mlir::presburger::IntegerRelation::setDimSymbolSeparation().
Swaps the posA^th variable of kindA and posB^th variable of kindB.
Definition at line 133 of file PresburgerSpace.cpp.
References atId(), and mlir::presburger::Local.
|
static |
Definition at line 213 of file PresburgerSpace.h.