14 #ifndef MLIR_ANALYSIS_PRESBURGER_PRESBURGERSPACE_H
15 #define MLIR_ANALYSIS_PRESBURGER_PRESBURGERSPACE_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/Support/ErrorHandling.h"
20 #include "llvm/Support/PointerLikeTypeTraits.h"
21 #include "llvm/Support/raw_ostream.h"
24 namespace presburger {
80 unsigned numRange = 0,
81 unsigned numSymbols = 0,
82 unsigned numLocals = 0) {
87 unsigned numSymbols = 0,
88 unsigned numLocals = 0) {
109 return numDomain + numRange + numSymbols;
112 return numDomain + numRange + numSymbols + numLocals;
127 unsigned varLimit)
const;
163 void print(llvm::raw_ostream &os)
const;
172 template <
typename T>
174 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
175 assert(TypeID::get<T>() == idType &&
"Type mismatch");
177 atId(kind, i) = llvm::PointerLikeTypeTraits<T>::getAsVoidPointer(
id);
182 template <
typename T>
184 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
185 assert(TypeID::get<T>() == idType &&
"Type mismatch");
187 return llvm::PointerLikeTypeTraits<T>::getFromVoidPointer(
atId(kind, i));
193 return atId(kind, i) !=
nullptr;
205 template <
typename T>
209 if (
hasId(kind, i) && getId<T>(kind, i) ==
id)
220 template <
typename T>
224 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
225 idType = TypeID::get<T>();
239 unsigned numSymbols = 0,
unsigned numLocals = 0)
240 : numDomain(numDomain), numRange(numRange), numSymbols(numSymbols),
241 numLocals(numLocals) {}
244 assert(usingIds &&
"Cannot access identifiers when `usingIds` is false.");
246 "Local variables cannot have identifiers.");
251 assert(usingIds &&
"Cannot access identifiers when `usingIds` is false.");
253 "Local variables cannot have identifiers.");
273 bool usingIds =
false;
275 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
This class provides an efficient unique identifier for a specific C++ type.
PresburgerSpace is the space of all possible values of a tuple of integer valued variables/variables.
unsigned getNumRangeVars() const
PresburgerSpace getRangeSpace() const
void resetIds()
Reset the stored identifiers in the space.
void setId(VarKind kind, unsigned i, T id)
Set the identifier for i^th variable to id.
unsigned getNumSymbolVars() const
unsigned getNumVarKind(VarKind kind) const
Get the number of vars of the specified kind.
void * atId(VarKind kind, unsigned i) const
PresburgerSpace(unsigned numDomain=0, unsigned numRange=0, unsigned numSymbols=0, unsigned numLocals=0)
unsigned getNumDimAndSymbolVars() const
bool isEqual(const PresburgerSpace &other) const
Returns true if both the spaces are equal including local variables i.e.
PresburgerSpace getDomainSpace() const
Get the domain/range space of this space.
void disableIds()
Disable identifiers being stored in space.
bool isUsingIds() const
Returns if identifiers are being used.
void removeVarRange(VarKind kind, unsigned varStart, unsigned varLimit)
Removes variables of the specified kind in the column range [varStart, varLimit).
unsigned getVarKindOffset(VarKind kind) const
Return the index at which the specified kind of var starts.
void setVarSymbolSeperation(unsigned newSymbolCount)
Changes the partition between dimensions and symbols.
unsigned getVarKindEnd(VarKind kind) const
Return the index at Which the specified kind of var ends.
unsigned getNumVars() const
unsigned getNumLocalVars() const
VarKind getVarKindAt(unsigned pos) const
Return the VarKind of the var at the specified position.
unsigned findId(VarKind kind, T id) const
Find the variable of the specified kind with identifier id.
unsigned getNumDomainVars() const
unsigned getVarKindOverlap(VarKind kind, unsigned varStart, unsigned varLimit) const
Get the number of elements of the specified kind in the range [varStart, varLimit).
static PresburgerSpace getSetSpace(unsigned numDims=0, unsigned numSymbols=0, unsigned numLocals=0)
bool isCompatible(const PresburgerSpace &other) const
Returns true if both the spaces are compatible i.e.
void print(llvm::raw_ostream &os) const
bool isAligned(const PresburgerSpace &other) const
Check if the spaces are compatible, as well as have the same identifiers for each variable.
PresburgerSpace getSpaceWithoutLocals() const
Get the space without local variables.
void *& atId(VarKind kind, unsigned i)
static const unsigned kIdNotFound
unsigned getNumDimVars() const
static PresburgerSpace getRelationSpace(unsigned numDomain=0, unsigned numRange=0, unsigned numSymbols=0, unsigned numLocals=0)
T getId(VarKind kind, unsigned i) const
Get the identifier for i^th variable casted to type T.
bool hasId(VarKind kind, unsigned i) const
Check if the i^th variable of the specified kind has a non-null identifier.
void swapVar(VarKind kindA, VarKind kindB, unsigned posA, unsigned posB)
Swaps the posA^th variable of kindA and posB^th variable of kindB.
unsigned getNumSetDimVars() const
unsigned insertVar(VarKind kind, unsigned pos, unsigned num=1)
Insert num variables of the specified kind at position pos.
This header declares functions that assit transformations in the MemRef dialect.
Represents a range (offset, size, and stride) where each element of the triple may be dynamic or stat...