MLIR  19.0.0git
Public Member Functions | Static Public Member Functions | 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"

+ Inheritance diagram for mlir::presburger::PresburgerSpace:

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 convertVarKind (VarKind srcKind, unsigned srcPos, unsigned num, VarKind dstKind, unsigned dstPos)
 Converts variables of the specified kind in the column range [srcPos, srcPos + num) to variables of the specified kind at position dstPos. More...
 
void setVarSymbolSeperation (unsigned newSymbolCount)
 Changes the partition between dimensions and symbols. 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...
 
Identifier getId (VarKind kind, unsigned pos) const
 Get the identifier of pos^th variable of the specified kind. More...
 
ArrayRef< IdentifiergetIds (VarKind kind) const
 
ArrayRef< IdentifiergetIds () const
 
void setId (VarKind kind, unsigned pos, Identifier id)
 Set the identifier of pos^th variable of the specified kind. More...
 
bool isUsingIds () const
 Returns if identifiers are being used. More...
 
void resetIds ()
 Reset the stored identifiers in the space. More...
 
void disableIds ()
 Disable identifiers being stored in space. More...
 
bool isAligned (const PresburgerSpace &other) const
 Check if the spaces are compatible, and the non-local variables having same identifiers are in the same positions. More...
 
bool isAligned (const PresburgerSpace &other, VarKind kind) const
 Same as above but only check the specified VarKind. More...
 
void mergeAndAlignSymbols (PresburgerSpace &other)
 Merge and align symbol variables of this and other with respect to identifiers. More...
 
void print (llvm::raw_ostream &os) const
 
void dump () const
 

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)
 

Protected Member Functions

 PresburgerSpace (unsigned numDomain, unsigned numRange, unsigned numSymbols, unsigned numLocals)
 

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 an Identifier with each non-local variable in the space. This is disabled by default. resetIds is used to enable/reset these identifiers. The user can identify each variable in the space as corresponding to some Identifier. Some example use cases are described in the Identifier documentation above. The type attached to the Identifier can be different for different variables in the space.

Definition at line 159 of file PresburgerSpace.h.

Constructor & Destructor Documentation

◆ PresburgerSpace()

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

Definition at line 315 of file PresburgerSpace.h.

Referenced by getRelationSpace(), and getSetSpace().

Member Function Documentation

◆ convertVarKind()

void PresburgerSpace::convertVarKind ( VarKind  srcKind,
unsigned  srcPos,
unsigned  num,
VarKind  dstKind,
unsigned  dstPos 
)

Converts variables of the specified kind in the column range [srcPos, srcPos + num) to variables of the specified kind at position dstPos.

The ranges are relative to the kind of variable.

srcKind and dstKind must be different.

Definition at line 158 of file PresburgerSpace.cpp.

References getNumVarKind(), getVarKindOffset(), isUsingIds(), and mlir::presburger::Local.

Referenced by mlir::presburger::PresburgerRelation::convertVarKind(), mlir::presburger::IntegerRelation::convertVarKind(), and getDomainSpace().

◆ disableIds()

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

Disable identifiers being stored in space.

Definition at line 293 of file PresburgerSpace.h.

◆ dump()

void PresburgerSpace::dump ( ) const

Definition at line 355 of file PresburgerSpace.cpp.

References print().

◆ getDomainSpace()

PresburgerSpace PresburgerSpace::getDomainSpace ( ) const

◆ getId()

Identifier mlir::presburger::PresburgerSpace::getId ( VarKind  kind,
unsigned  pos 
) const
inline

◆ getIds() [1/2]

ArrayRef<Identifier> mlir::presburger::PresburgerSpace::getIds ( ) const
inline

Definition at line 267 of file PresburgerSpace.h.

Referenced by mergeAndAlignSymbols().

◆ getIds() [2/2]

ArrayRef<Identifier> mlir::presburger::PresburgerSpace::getIds ( VarKind  kind) const
inline

◆ getNumDimAndSymbolVars()

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

◆ getNumDimVars()

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

Definition at line 189 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 185 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 56 of file PresburgerSpace.cpp.

Referenced by mlir::presburger::PresburgerRelation::convertVarKind(), convertVarKind(), and mergeAndAlignSymbols().

◆ getNumVars()

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

◆ getRangeSpace()

PresburgerSpace PresburgerSpace::getRangeSpace ( ) const

◆ 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 50 of file PresburgerSpace.cpp.

References getNumLocalVars(), 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 80 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 68 of file PresburgerSpace.cpp.

Referenced by convertVarKind(), mlir::presburger::IntegerRelation::fourierMotzkinEliminate(), and swapVar().

◆ 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 84 of file PresburgerSpace.cpp.

◆ 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 112 of file PresburgerSpace.cpp.

Referenced by mergeAndAlignSymbols(), 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, and the non-local variables having same identifiers are in the same positions.

If the space is not using Identifiers, this check is same as isCompatible.

Definition at line 254 of file PresburgerSpace.cpp.

References areIdsEqual(), mlir::presburger::Domain, isCompatible(), isUsingIds(), mlir::presburger::Range, and mlir::presburger::Symbol.

◆ isAligned() [2/2]

bool PresburgerSpace::isAligned ( const PresburgerSpace other,
VarKind  kind 
) const

Same as above but only check the specified VarKind.

Useful to check if the symbols in two spaces are aligned.

Definition at line 272 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 236 of file PresburgerSpace.cpp.

References getNumLocalVars(), and isCompatible().

Referenced by mlir::presburger::IntegerRelation::append(), mlir::presburger::IntegerRelation::isObviouslyEqual(), and mlir::presburger::IntegerRelation::unionBoundingBox().

◆ isUsingIds()

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

◆ mergeAndAlignSymbols()

void PresburgerSpace::mergeAndAlignSymbols ( PresburgerSpace other)

Merge and align symbol variables of this and other with respect to identifiers.

After this operation the symbol variables of both spaces have the same identifiers in the same order.

Definition at line 298 of file PresburgerSpace.cpp.

References getId(), getIds(), getNumVarKind(), insertVar(), setId(), and mlir::presburger::Symbol.

◆ print()

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

◆ removeVarRange()

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

◆ resetIds()

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

Reset the stored identifiers in the space.

Enables usingIds if it was false before.

Definition at line 286 of file PresburgerSpace.h.

References getNumDimAndSymbolVars().

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

◆ setId()

void mlir::presburger::PresburgerSpace::setId ( VarKind  kind,
unsigned  pos,
Identifier  id 
)
inline

Set the identifier of pos^th variable of the specified kind.

Calls resetIds if identifiers are not enabled.

Definition at line 274 of file PresburgerSpace.h.

Referenced by mlir::presburger::IntegerRelation::mergeAndAlignSymbols(), mergeAndAlignSymbols(), mlir::presburger::IntegerRelation::mergeAndCompose(), and swapVar().

◆ 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 289 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 208 of file PresburgerSpace.cpp.

References getVarKindOffset(), isUsingIds(), mlir::presburger::Local, and setId().

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


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