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 {
75 : value(
llvm::PointerLikeTypeTraits<T>::getAsVoidPointer(value)) {
76 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
77 idType = TypeID::get<T>();
85 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
86 assert(TypeID::get<T>() == idType &&
87 "Identifier was initialized with a different type than the one used "
90 return llvm::PointerLikeTypeTraits<T>::getFromVoidPointer(value);
93 bool hasValue()
const {
return value !=
nullptr; }
102 void print(llvm::raw_ostream &os)
const;
107 void *value =
nullptr;
109 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
111 TypeID idType = TypeID::get<void>();
162 unsigned numRange = 0,
163 unsigned numSymbols = 0,
164 unsigned numLocals = 0) {
169 unsigned numSymbols = 0,
170 unsigned numLocals = 0) {
191 return numDomain + numRange + numSymbols;
194 return numDomain + numRange + numSymbols + numLocals;
209 unsigned varLimit)
const;
233 VarKind dstKind,
unsigned dstPos);
255 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
259 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
264 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
293 void print(llvm::raw_ostream &os)
const;
299 : numDomain(numDomain), numRange(numRange), numSymbols(numSymbols),
300 numLocals(numLocals) {}
318 bool usingIds =
false;
This class provides an efficient unique identifier for a specific C++ type.
An Identifier stores a pointer to an object, such as a Value or an Operation.
T getValue() const
Get the value of the identifier casted to type T.
bool operator!=(const Identifier &other) const
bool isEqual(const Identifier &other) const
Check if the two identifiers are equal.
void print(llvm::raw_ostream &os) const
bool operator==(const Identifier &other) const
PresburgerSpace is the space of all possible values of a tuple of integer valued variables/variables.
unsigned getNumRangeVars() const
PresburgerSpace getRangeSpace() const
unsigned getNumSymbolVars() const
unsigned getNumVarKind(VarKind kind) const
Get the number of vars of the specified kind.
void resetIds()
Reset the stored identifiers in the space.
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.
Identifier & getId(VarKind kind, unsigned pos)
Get the identifier of the specified variable.
void disableIds()
Disable identifiers being stored in space.
bool isUsingIds() const
Returns if identifiers are being used.
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 t...
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.
Identifier getId(VarKind kind, unsigned pos) const
unsigned getNumVars() const
PresburgerSpace(unsigned numDomain, unsigned numRange, unsigned numSymbols, unsigned numLocals)
unsigned getNumLocalVars() const
VarKind getVarKindAt(unsigned pos) const
Return the VarKind of the var at the specified position.
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)
ArrayRef< Identifier > getIds(VarKind kind) const
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, and the non-local variables having same identifiers are in the sa...
PresburgerSpace getSpaceWithoutLocals() const
Get the space without local variables.
unsigned getNumDimVars() const
static PresburgerSpace getRelationSpace(unsigned numDomain=0, unsigned numRange=0, unsigned numSymbols=0, unsigned numLocals=0)
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.
Include the generated interface declarations.
Include the generated interface declarations.
Represents a range (offset, size, and stride) where each element of the triple may be dynamic or stat...