MLIR  17.0.0git
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
mlir::presburger::PresburgerSpace Class Reference

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 >
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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PresburgerSpace()

mlir::presburger::PresburgerSpace::PresburgerSpace ( unsigned  numDomain = 0,
unsigned  numRange = 0,
unsigned  numSymbols = 0,
unsigned  numLocals = 0 
)
inlineprotected

Definition at line 238 of file PresburgerSpace.h.

Referenced by getRelationSpace(), and getSetSpace().

Member Function Documentation

◆ atId() [1/2]

void*& mlir::presburger::PresburgerSpace::atId ( VarKind  kind,
unsigned  i 
)
inlineprotected

Definition at line 243 of file PresburgerSpace.h.

Referenced by swapVar().

◆ atId() [2/2]

void* mlir::presburger::PresburgerSpace::atId ( VarKind  kind,
unsigned  i 
) const
inlineprotected

Definition at line 250 of file PresburgerSpace.h.

◆ disableIds()

void mlir::presburger::PresburgerSpace::disableIds ( )
inline

Disable identifiers being stored in space.

Definition at line 232 of file PresburgerSpace.h.

◆ dump()

void PresburgerSpace::dump ( ) const

Definition at line 213 of file PresburgerSpace.cpp.

References print().

◆ findId()

template<typename T >
unsigned mlir::presburger::PresburgerSpace::findId ( VarKind  kind,
id 
) const
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.

◆ getDomainSpace()

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().

◆ getId()

template<typename T >
T mlir::presburger::PresburgerSpace::getId ( VarKind  kind,
unsigned  i 
) const
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.

◆ getNumDimAndSymbolVars()

unsigned mlir::presburger::PresburgerSpace::getNumDimAndSymbolVars ( ) const
inline

◆ getNumDimVars()

unsigned mlir::presburger::PresburgerSpace::getNumDimVars ( ) const
inline

Definition at line 107 of file PresburgerSpace.h.

Referenced by mlir::presburger::IntegerRelation::getNumDimVars().

◆ getNumDomainVars()

unsigned mlir::presburger::PresburgerSpace::getNumDomainVars ( ) const
inline

◆ getNumLocalVars()

unsigned mlir::presburger::PresburgerSpace::getNumLocalVars ( ) const
inline

◆ getNumRangeVars()

unsigned mlir::presburger::PresburgerSpace::getNumRangeVars ( ) const
inline

◆ getNumSetDimVars()

unsigned mlir::presburger::PresburgerSpace::getNumSetDimVars ( ) const
inline

Definition at line 103 of file PresburgerSpace.h.

◆ getNumSymbolVars()

unsigned mlir::presburger::PresburgerSpace::getNumSymbolVars ( ) const
inline

◆ getNumVarKind()

unsigned PresburgerSpace::getNumVarKind ( VarKind  kind) const

Get the number of vars of the specified kind.

Definition at line 31 of file PresburgerSpace.cpp.

◆ getNumVars()

unsigned mlir::presburger::PresburgerSpace::getNumVars ( ) const
inline

◆ getRangeSpace()

PresburgerSpace PresburgerSpace::getRangeSpace ( ) const

Definition at line 21 of file PresburgerSpace.cpp.

References getSetSpace().

Referenced by mlir::presburger::MultiAffineFunction::getOutputSpace().

◆ getRelationSpace()

static PresburgerSpace mlir::presburger::PresburgerSpace::getRelationSpace ( unsigned  numDomain = 0,
unsigned  numRange = 0,
unsigned  numSymbols = 0,
unsigned  numLocals = 0 
)
inlinestatic

◆ getSetSpace()

static PresburgerSpace mlir::presburger::PresburgerSpace::getSetSpace ( unsigned  numDims = 0,
unsigned  numSymbols = 0,
unsigned  numLocals = 0 
)
inlinestatic

◆ getSpaceWithoutLocals()

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().

◆ getVarKindAt()

VarKind PresburgerSpace::getVarKindAt ( unsigned  pos) const

◆ getVarKindEnd()

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().

◆ getVarKindOffset()

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().

◆ getVarKindOverlap()

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.

◆ hasId()

bool mlir::presburger::PresburgerSpace::hasId ( VarKind  kind,
unsigned  i 
) const
inline

Check if the i^th variable of the specified kind has a non-null identifier.

Definition at line 192 of file PresburgerSpace.h.

◆ insertVar()

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().

◆ isAligned() [1/2]

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().

◆ isAligned() [2/2]

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.

◆ isCompatible()

bool PresburgerSpace::isCompatible ( const PresburgerSpace other) const

◆ isEqual()

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().

◆ isUsingIds()

bool mlir::presburger::PresburgerSpace::isUsingIds ( ) const
inline

Returns if identifiers are being used.

Definition at line 216 of file PresburgerSpace.h.

Referenced by isAligned().

◆ print()

void PresburgerSpace::print ( llvm::raw_ostream &  os) const

◆ removeVarRange()

void PresburgerSpace::removeVarRange ( VarKind  kind,
unsigned  varStart,
unsigned  varLimit 
)

◆ resetIds()

template<typename T >
void mlir::presburger::PresburgerSpace::resetIds ( )
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().

◆ setId()

template<typename T >
void mlir::presburger::PresburgerSpace::setId ( VarKind  kind,
unsigned  i,
id 
)
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.

◆ setVarSymbolSeperation()

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().

◆ swapVar()

void PresburgerSpace::swapVar ( VarKind  kindA,
VarKind  kindB,
unsigned  posA,
unsigned  posB 
)

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.

Member Data Documentation

◆ kIdNotFound

const unsigned mlir::presburger::PresburgerSpace::kIdNotFound = UINT_MAX
static

Definition at line 213 of file PresburgerSpace.h.


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