14 using namespace presburger;
40 llvm_unreachable(
"VarKind does not exist!");
52 llvm_unreachable(
"VarKind does not exist!");
60 unsigned varLimit)
const {
66 unsigned overlapStart =
std::max(varStart, varRangeStart);
67 unsigned overlapEnd =
std::min(varLimit, varRangeEnd);
69 if (overlapStart > overlapEnd)
71 return overlapEnd - overlapStart;
75 assert(pos <
getNumVars() &&
"`pos` should represent a valid var position");
84 llvm_unreachable(
"`pos` should represent a valid var position");
104 identifiers.insert(identifiers.begin() + absolutePos, num,
nullptr);
111 assert(varLimit <=
getNumVarKind(kind) &&
"invalid var limit");
113 if (varStart >= varLimit)
116 unsigned numVarsEliminated = varLimit - varStart;
118 numDomain -= numVarsEliminated;
120 numRange -= numVarsEliminated;
122 numSymbols -= numVarsEliminated;
124 numLocals -= numVarsEliminated;
143 atId(kindB, posB) =
nullptr;
148 atId(kindA, posA) =
nullptr;
152 std::swap(
atId(kindA, posA),
atId(kindB, posB));
167 "Both spaces should be using identifiers to check for "
169 return isCompatible(other) && identifiers == other.identifiers;
175 "Both spaces should be using identifiers to check for "
183 return kindAttachments == otherKindAttachments;
188 "invalid separation position");
189 numRange = numRange + numSymbols - newSymbolCount;
190 numSymbols = newSymbolCount;
202 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
203 os <<
"TypeID of identifiers: " << idType.getAsOpaquePointer() <<
"\n";
207 for (
void *identifier : identifiers)
208 os << identifier <<
" ";
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
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.
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.
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 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)
unsigned getNumDimVars() const
void swapVar(VarKind kindA, VarKind kindB, unsigned posA, unsigned posB)
Swaps the posA^th variable of kindA and posB^th variable of kindB.
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.