MLIR  20.0.0git
Classes | Public Member Functions | List of all members
mlir::presburger::PWMAFunction Class Reference

This class represents a piece-wise MultiAffineFunction. More...

#include "mlir/Analysis/Presburger/PWMAFunction.h"

Classes

struct  Piece
 

Public Member Functions

 PWMAFunction (const PresburgerSpace &space)
 
const PresburgerSpacegetSpace () const
 
void addPiece (const Piece &piece)
 
unsigned getNumPieces () const
 
unsigned getNumVarKind (VarKind kind) const
 
unsigned getNumDomainVars () const
 
unsigned getNumOutputs () const
 
unsigned getNumSymbolVars () const
 
void removeOutputs (unsigned start, unsigned end)
 Remove the specified range of outputs. More...
 
PresburgerSpace getDomainSpace () const
 Get the domain/output space of the function. More...
 
PresburgerSpace getOutputSpace () const
 
PresburgerSet getDomain () const
 Return the domain of this piece-wise MultiAffineFunction. More...
 
std::optional< SmallVector< DynamicAPInt, 8 > > valueAt (ArrayRef< DynamicAPInt > point) const
 Return the output of the function at the given point. More...
 
std::optional< SmallVector< DynamicAPInt, 8 > > valueAt (ArrayRef< int64_t > point) const
 
ArrayRef< PiecegetAllPieces () const
 Return all the pieces of this piece-wise function. More...
 
bool isEqual (const PWMAFunction &other) const
 Return whether this and other are equal as PWMAFunctions, i.e. More...
 
PWMAFunction unionLexMin (const PWMAFunction &func)
 Return a function defined on the union of the domains of this and func, such that when only one of the functions is defined, it outputs the same as that function, and if both are defined, it outputs the lexmax/lexmin of the two outputs. More...
 
PWMAFunction unionLexMax (const PWMAFunction &func)
 
void print (raw_ostream &os) const
 
void dump () const
 

Detailed Description

This class represents a piece-wise MultiAffineFunction.

This can be thought of as a list of MultiAffineFunction with disjoint domains, with each having their own affine expressions for their output tuples. For example, we could have a function with two input variables (x, y), defined as

f(x, y) = (2*x + y, y - 4) if x >= 0, y >= 0 = (-2*x + y, y + 4) if x < 0, y < 0 = (4, 1) if x < 0, y >= 0

Note that the domains all have to be disjoint. Otherwise, the behaviour of this class is undefined. The domains need not cover all possible points; this represents a partial function and so could be undefined at some points.

As in PresburgerSets, the input vars are partitioned into dimension vars and symbolic vars.

Support is provided to compare equality of two such functions as well as finding the value of the function at a point.

Definition at line 153 of file PWMAFunction.h.

Constructor & Destructor Documentation

◆ PWMAFunction()

mlir::presburger::PWMAFunction::PWMAFunction ( const PresburgerSpace space)
inline

Member Function Documentation

◆ addPiece()

void PWMAFunction::addPiece ( const Piece piece)

◆ dump()

void PWMAFunction::dump ( ) const

Definition at line 314 of file PWMAFunction.cpp.

References print().

◆ getAllPieces()

ArrayRef<Piece> mlir::presburger::PWMAFunction::getAllPieces ( ) const
inline

Return all the pieces of this piece-wise function.

Definition at line 204 of file PWMAFunction.h.

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

◆ getDomain()

PresburgerSet PWMAFunction::getDomain ( ) const

Return the domain of this piece-wise MultiAffineFunction.

This is the union of the domains of all the pieces.

Definition at line 53 of file PWMAFunction.cpp.

References getDomainSpace(), mlir::presburger::PresburgerSet::getEmpty(), and mlir::presburger::PresburgerRelation::unionInPlace().

Referenced by addPiece(), mlir::presburger::IntegerRelation::computeReprWithOnlyDivLocals(), and isEqual().

◆ getDomainSpace()

PresburgerSpace mlir::presburger::PWMAFunction::getDomainSpace ( ) const
inline

Get the domain/output space of the function.

The returned space is a set space.

Definition at line 188 of file PWMAFunction.h.

References mlir::presburger::PresburgerSpace::getDomainSpace().

Referenced by getDomain().

◆ getNumDomainVars()

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

Definition at line 179 of file PWMAFunction.h.

References mlir::presburger::PresburgerSpace::getNumDomainVars().

Referenced by valueAt().

◆ getNumOutputs()

unsigned mlir::presburger::PWMAFunction::getNumOutputs ( ) const
inline

◆ getNumPieces()

unsigned mlir::presburger::PWMAFunction::getNumPieces ( ) const
inline

Definition at line 175 of file PWMAFunction.h.

Referenced by print().

◆ getNumSymbolVars()

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

Definition at line 181 of file PWMAFunction.h.

References mlir::presburger::PresburgerSpace::getNumSymbolVars().

Referenced by valueAt().

◆ getNumVarKind()

unsigned mlir::presburger::PWMAFunction::getNumVarKind ( VarKind  kind) const
inline

◆ getOutputSpace()

PresburgerSpace mlir::presburger::PWMAFunction::getOutputSpace ( ) const
inline

◆ getSpace()

const PresburgerSpace& mlir::presburger::PWMAFunction::getSpace ( ) const
inline

◆ isEqual()

bool PWMAFunction::isEqual ( const PWMAFunction other) const

Return whether this and other are equal as PWMAFunctions, i.e.

Two PWMAFunctions are equal if they have the same dimensionalities, the same domain, and take the same value at every point in the domain.

whether they have the same dimensions, the same domain and they take the same value at every point in the domain.

Definition at line 277 of file PWMAFunction.cpp.

References getDomain(), and mlir::presburger::PresburgerSpace::isCompatible().

◆ print()

void PWMAFunction::print ( raw_ostream &  os) const

Definition at line 303 of file PWMAFunction.cpp.

References getNumPieces(), and mlir::presburger::PresburgerSpace::print().

Referenced by dump().

◆ removeOutputs()

void PWMAFunction::removeOutputs ( unsigned  start,
unsigned  end 
)

Remove the specified range of outputs.

Definition at line 461 of file PWMAFunction.cpp.

References mlir::presburger::Range, and mlir::presburger::PresburgerSpace::removeVarRange().

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

◆ unionLexMax()

PWMAFunction PWMAFunction::unionLexMax ( const PWMAFunction func)

Definition at line 383 of file PWMAFunction.cpp.

Referenced by findSymbolicIntegerLexOpt().

◆ unionLexMin()

PWMAFunction PWMAFunction::unionLexMin ( const PWMAFunction func)

Return a function defined on the union of the domains of this and func, such that when only one of the functions is defined, it outputs the same as that function, and if both are defined, it outputs the lexmax/lexmin of the two outputs.

On points where neither function is defined, the returned function is not defined either.

Currently this does not support PWMAFunctions which have pieces containing divisions. TODO: Support division in pieces.

Definition at line 379 of file PWMAFunction.cpp.

Referenced by findSymbolicIntegerLexOpt().

◆ valueAt() [1/2]

std::optional< SmallVector< DynamicAPInt, 8 > > PWMAFunction::valueAt ( ArrayRef< DynamicAPInt >  point) const

Return the output of the function at the given point.

Definition at line 468 of file PWMAFunction.cpp.

References getNumDomainVars(), and getNumSymbolVars().

Referenced by valueAt().

◆ valueAt() [2/2]

std::optional<SmallVector<DynamicAPInt, 8> > mlir::presburger::PWMAFunction::valueAt ( ArrayRef< int64_t >  point) const
inline

Definition at line 199 of file PWMAFunction.h.

References mlir::presburger::getDynamicAPIntVec(), and valueAt().


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