14 #ifndef MLIR_ANALYSIS_PRESBURGER_PRESBURGERSPACE_H
15 #define MLIR_ANALYSIS_PRESBURGER_PRESBURGERSPACE_H
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Support/PointerLikeTypeTraits.h"
20 #include "llvm/Support/TypeName.h"
21 #include "llvm/Support/raw_ostream.h"
24 namespace presburger {
77 : value(
llvm::PointerLikeTypeTraits<T>::getAsVoidPointer(value)) {
78 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
79 idType = llvm::getTypeName<T>();
87 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
88 assert(llvm::getTypeName<T>() == idType &&
89 "Identifier was initialized with a different type than the one used "
92 return llvm::PointerLikeTypeTraits<T>::getFromVoidPointer(value);
95 bool hasValue()
const {
return value !=
nullptr; }
104 void print(llvm::raw_ostream &os)
const;
109 void *value =
nullptr;
111 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
113 llvm::StringRef idType;
164 unsigned numRange = 0,
165 unsigned numSymbols = 0,
166 unsigned numLocals = 0) {
171 unsigned numSymbols = 0,
172 unsigned numLocals = 0) {
193 return numDomain + numRange + numSymbols;
196 return numDomain + numRange + numSymbols + numLocals;
211 unsigned varLimit)
const;
235 VarKind dstKind,
unsigned dstPos);
257 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
264 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
265 assert(usingIds &&
"Identifiers not enabled for space");
270 assert(usingIds &&
"Identifiers not enabled for space");
277 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
313 void print(llvm::raw_ostream &os)
const;
319 : numDomain(numDomain), numRange(numRange), numSymbols(numSymbols),
320 numLocals(numLocals) {}
338 bool usingIds =
false;
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
ArrayRef< Identifier > getIds() const
PresburgerSpace getRangeSpace() const
void setId(VarKind kind, unsigned pos, Identifier id)
Set the identifier of pos^th variable of the specified kind.
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.
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.
unsigned getVarKindEnd(VarKind kind) const
Return the index at Which the specified kind of var ends.
Identifier getId(VarKind kind, unsigned pos) const
Get the identifier of pos^th variable of the specified kind.
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
void mergeAndAlignSymbols(PresburgerSpace &other)
Merge and align symbol variables of this and other with respect to identifiers.
void setVarSymbolSeparation(unsigned newSymbolCount)
Changes the partition between dimensions and symbols.
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.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
Represents a range (offset, size, and stride) where each element of the triple may be dynamic or stat...