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"
26using llvm::SmallVector;
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;
105#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
106 LLVM_DUMP_METHOD
void dump()
const;
111 void *value =
nullptr;
113#if LLVM_ENABLE_ABI_BREAKING_CHECKS
115 llvm::StringRef idType;
166 unsigned numRange = 0,
167 unsigned numSymbols = 0,
168 unsigned numLocals = 0) {
173 unsigned numSymbols = 0,
174 unsigned numLocals = 0) {
195 return numDomain + numRange + numSymbols;
198 return numDomain + numRange + numSymbols + numLocals;
213 unsigned varLimit)
const;
237 VarKind dstKind,
unsigned dstPos);
259 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
266 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
267 assert(usingIds &&
"Identifiers not enabled for space");
272 assert(usingIds &&
"Identifiers not enabled for space");
279 assert(kind !=
VarKind::Local &&
"Local variables have no identifiers");
315 void print(llvm::raw_ostream &os)
const;
316#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
317 LLVM_DUMP_METHOD
void dump()
const;
323 : numDomain(numDomain), numRange(numRange), numSymbols(numSymbols),
324 numLocals(numLocals) {}
342 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.
LLVM_DUMP_METHOD void dump() const
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
LLVM_DUMP_METHOD void dump() 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).
ArrayRef< Identifier > getIds(VarKind kind) const
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
ArrayRef< Identifier > getIds() 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)
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.