17 : map(map), operands(operands.begin(), operands.end()),
18 results(results.begin(), results.end()) {}
23 this->operands.assign(operands.begin(), operands.end());
24 this->results.assign(results.begin(), results.end());
33 this->map.reset(sMap);
40 "matching by position requires equal result counts");
41 bool validExpr =
true;
43 if (
auto dim = llvm::dyn_cast<AffineDimExpr>(subExpr))
44 validExpr &= dim.getPosition() < 2;
45 else if (llvm::isa<AffineSymbolExpr>(subExpr))
48 assert(validExpr &&
"combining expression must use only d0 and d1");
53 auto bDims =
b.getOperands().take_front(
b.getNumDims());
55 auto bSyms =
b.getOperands().take_back(
b.getNumSymbols());
56 allOperands.append(aDims.begin(), aDims.end());
57 allOperands.append(bDims.begin(), bDims.end());
58 allOperands.append(aSyms.begin(), aSyms.end());
59 allOperands.append(bSyms.begin(), bSyms.end());
62 auto bMap =
b.getAffineMap()
71 for (
auto [aResult, bResult] :
72 llvm::zip_equal(aMap.getResults(), bMap.getResults())) {
73 AffineExpr replacements[] = {aResult, bResult};
74 resultExprs.push_back(expr.
replaceDims(replacements));
80 AffineExpr replacements[] = {aResult, bResult};
81 resultExprs.push_back(expr.
replaceDims(replacements));
85 auto resultMap =
AffineMap::get(bMap.getNumDims(), bMap.getNumSymbols(),
86 resultExprs, bMap.getContext());
90 res->reset(resultMap, allOperands);
107 combine(a,
b, lhs - rhs, res,
false);
113 unsigned indexStart,
unsigned *indexOfMatch) {
114 unsigned size = valuesToSearch.size();
115 for (
unsigned i = indexStart; i < size; ++i) {
116 if (valueToMatch == valuesToSearch[i]) {
125 return map.isMultipleOf(idx, factor);
142 return static_cast<Value>(operands[i]);
157 return e == getAffineConstantExpr(0, e.getContext());
static bool findIndex(Value valueToMatch, ArrayRef< Value > valuesToSearch, unsigned indexStart, unsigned *indexOfMatch)
Base type for affine expression.
RetT walk(FnT &&callback) const
Walk all of the AffineExpr's in this expression in postorder.
bool isFunctionOfDim(unsigned position) const
Return true if the affine expression involves AffineDimExpr position.
AffineExpr replaceDims(ArrayRef< AffineExpr > dimReplacements) const
Dim-only version of replaceDimsAndSymbols.
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
MLIRContext * getContext() const
static AffineMap get(MLIRContext *context)
Returns a zero result affine map with no dimensions or symbols: () -> ().
ArrayRef< AffineExpr > getResults() const
AffineExpr getResult(unsigned idx) const
MLIRContext is the top-level object for a collection of MLIR operations.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Value getOperand(unsigned i) const
static void cartesianProductDifference(const AffineValueMap &a, const AffineValueMap &b, AffineValueMap *res)
Subtract results of 'b' from results of 'a' over their Cartesian product.
bool operator==(const AffineValueMap &other) const
Checks if the application of this map to its operands is semantically equal to other's.
bool isMultipleOf(unsigned idx, int64_t factor) const
Return true if the idx^th result can be proved to be a multiple of 'factor', false otherwise.
static void combine(const AffineValueMap &a, const AffineValueMap &b, AffineExpr expr, AffineValueMap *res, bool pairwise=true)
Combine results from 'a' and 'b' using 'expr'.
void composeSimplifyAndCanonicalize()
Composes all incoming affine.apply ops and then simplifies and canonicalizes the map and operands.
unsigned getNumSymbols() const
ArrayRef< Value > getOperands() const
unsigned getNumDims() const
unsigned getNumOperands() const
AffineMap getAffineMap() const
bool isFunctionOf(unsigned idx, Value value) const
Return true if the idx^th result depends on 'value', false otherwise.
void reset(AffineMap map, ValueRange operands, ValueRange results={})
unsigned getNumResults() const
static void difference(const AffineValueMap &a, const AffineValueMap &b, AffineValueMap *res)
Subtract each result of 'b' from the result of 'a' at the same index; the result counts must be equal...
void canonicalizeMapAndOperands(AffineMap *map, SmallVectorImpl< Value > *operands)
Modifies both map and operands in-place so as to:
void fullyComposeAffineMapAndOperands(AffineMap *map, SmallVectorImpl< Value > *operands, bool composeAffineMin=false)
Given an affine map map and its input operands, this method composes into map, maps of AffineApplyOps...
Include the generated interface declarations.
AffineMap simplifyAffineMap(AffineMap map)
Simplifies an affine map by simplifying its underlying AffineExpr results.
AffineExpr getAffineDimExpr(unsigned position, MLIRContext *context)
These free functions allow clients of the API to not use classes in detail.