|
MLIR 22.0.0git
|
Base type for affine expression. More...
#include "mlir/IR/AffineExpr.h"
Public Types | |
| using | ImplType = detail::AffineExprStorage |
Public Member Functions | |
| constexpr | AffineExpr () |
| AffineExpr (const ImplType *expr) | |
| bool | operator== (AffineExpr other) const |
| bool | operator!= (AffineExpr other) const |
| bool | operator== (int64_t v) const |
| bool | operator!= (int64_t v) const |
| operator bool () const | |
| bool | operator! () const |
| MLIRContext * | getContext () const |
| AffineExprKind | getKind () const |
| Return the classification for this type. | |
| void | print (raw_ostream &os) const |
| void | dump () const |
| bool | isSymbolicOrConstant () const |
| Returns true if this expression is made out of only symbols and constants, i.e., it does not involve dimensional identifiers. | |
| bool | isPureAffine () const |
| Returns true if this is a pure affine expression, i.e., multiplication, floordiv, ceildiv, and mod is only allowed w.r.t constants. | |
| int64_t | getLargestKnownDivisor () const |
| Returns the greatest known integral divisor of this affine expression. | |
| bool | isMultipleOf (int64_t factor) const |
| Return true if the affine expression is a multiple of 'factor'. | |
| bool | isFunctionOfDim (unsigned position) const |
| Return true if the affine expression involves AffineDimExpr position. | |
| bool | isFunctionOfSymbol (unsigned position) const |
| Return true if the affine expression involves AffineSymbolExpr position. | |
| template<typename FnT, typename RetT = detail::walkResultType<FnT>> | |
| RetT | walk (FnT &&callback) const |
| Walk all of the AffineExpr's in this expression in postorder. | |
| AffineExpr | replaceDimsAndSymbols (ArrayRef< AffineExpr > dimReplacements, ArrayRef< AffineExpr > symReplacements) const |
| This method substitutes any uses of dimensions and symbols (e.g. | |
| AffineExpr | replaceDims (ArrayRef< AffineExpr > dimReplacements) const |
| Dim-only version of replaceDimsAndSymbols. | |
| AffineExpr | replaceSymbols (ArrayRef< AffineExpr > symReplacements) const |
| Symbol-only version of replaceDimsAndSymbols. | |
| AffineExpr | replace (AffineExpr expr, AffineExpr replacement) const |
| Sparse replace method. | |
| AffineExpr | replace (const DenseMap< AffineExpr, AffineExpr > &map) const |
| Sparse replace method. | |
| AffineExpr | shiftDims (unsigned numDims, unsigned shift, unsigned offset=0) const |
| Replace dims[offset ... numDims) by dims[offset + shift ... shift + numDims). | |
| AffineExpr | shiftSymbols (unsigned numSymbols, unsigned shift, unsigned offset=0) const |
| Replace symbols[offset ... numSymbols) by symbols[offset + shift ... shift + numSymbols). | |
| AffineExpr | operator+ (int64_t v) const |
| AffineExpr | operator+ (AffineExpr other) const |
| AffineExpr | operator- () const |
| AffineExpr | operator- (int64_t v) const |
| AffineExpr | operator- (AffineExpr other) const |
| AffineExpr | operator* (int64_t v) const |
| AffineExpr | operator* (AffineExpr other) const |
| AffineExpr | floorDiv (uint64_t v) const |
| AffineExpr | floorDiv (AffineExpr other) const |
| AffineExpr | ceilDiv (uint64_t v) const |
| AffineExpr | ceilDiv (AffineExpr other) const |
| AffineExpr | operator% (uint64_t v) const |
| AffineExpr | operator% (AffineExpr other) const |
| AffineExpr | compose (AffineMap map) const |
| Compose with an AffineMap. | |
| friend::llvm::hash_code | hash_value (AffineExpr arg) |
| const void * | getAsOpaquePointer () const |
| Methods supporting C API. | |
| ImplType * | getImpl () const |
Static Public Member Functions | |
| static AffineExpr | getFromOpaquePointer (const void *pointer) |
Protected Attributes | |
| ImplType * | expr {nullptr} |
Base type for affine expression.
AffineExpr's are immutable value types with intuitive operators to operate on chainable, lightweight compositions. An AffineExpr is an interface to the underlying storage type pointer.
Definition at line 68 of file AffineExpr.h.
Definition at line 70 of file AffineExpr.h.
|
inlineconstexpr |
Definition at line 72 of file AffineExpr.h.
Referenced by mlir::AffineBinaryOpExpr::AffineBinaryOpExpr(), mlir::AffineDimExpr::AffineDimExpr(), ceilDiv(), ceilDiv(), compose(), floorDiv(), floorDiv(), getFromOpaquePointer(), mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineBinaryOpExpr::getRHS(), hash_value(), operator!=(), operator%(), operator%(), operator*(), operator*(), operator+(), operator+(), operator-(), operator-(), operator-(), operator==(), replace(), replaceDims(), shiftDims(), and shiftSymbols().
|
inline |
Definition at line 73 of file AffineExpr.h.
References expr.
| AffineExpr AffineExpr::ceilDiv | ( | AffineExpr | other | ) | const |
Definition at line 1009 of file AffineExpr.cpp.
References AffineExpr(), mlir::CeilDiv, mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), and simplifyCeilDiv().
| AffineExpr AffineExpr::ceilDiv | ( | uint64_t | v | ) | const |
Definition at line 1006 of file AffineExpr.cpp.
References AffineExpr(), ceilDiv(), mlir::getAffineConstantExpr(), and getContext().
Referenced by calculateTileOffsetsAndSizes(), ceilDiv(), mlir::linalg::computePaddedShape(), createInitialTensorsForTiling(), mlir::affine::getTripCountMapAndOperands(), getUserTileSizesAndNumThreads(), mlir::linalg::packMatmulGreedily(), and replaceAffineMinBoundingBoxExpression().
| AffineExpr AffineExpr::compose | ( | AffineMap | map | ) | const |
Compose with an AffineMap.
Returns the composition of this AffineExpr with map.
Prerequisites: this and map are composable, i.e. that the number of AffineDimExpr of this is smaller than the number of results of map. If a result of a map does not have a corresponding AffineDimExpr, that result simply does not appear in the produced AffineExpr.
Example: expr: d0 + d2 map: (d0, d1, d2)[s0, s1] -> (d0 + s1, d1 + s0, d0 + d1 + d2) returned expr: d0 * 2 + d1 + d2 + s1
Definition at line 1076 of file AffineExpr.cpp.
References AffineExpr(), mlir::AffineMap::getResults(), and replaceDimsAndSymbols().
Referenced by mlir::AffineMap::compose().
| void AffineExpr::dump | ( | ) | const |
Definition at line 4022 of file AsmPrinter.cpp.
References print().
| AffineExpr AffineExpr::floorDiv | ( | AffineExpr | other | ) | const |
Definition at line 962 of file AffineExpr.cpp.
References AffineExpr(), mlir::FloorDiv, mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), and simplifyFloorDiv().
| AffineExpr AffineExpr::floorDiv | ( | uint64_t | v | ) | const |
Definition at line 959 of file AffineExpr.cpp.
References AffineExpr(), floorDiv(), mlir::getAffineConstantExpr(), and getContext().
Referenced by common3DIdBuilderFn(), commonLinearIdBuilderFn(), mlir::linalg::computeContinuousTileSizes(), mlir::linalg::computeMultiTileSizes(), mlir::memref::createExpandStridedMetadataPass(), mlir::delinearize(), mlir::gpu::WarpDistributionPattern::delinearizeLaneId(), floorDiv(), mlir::FlatLinearConstraints::getConstantBoundOnDimSize(), getIndicesForLoadOrStore(), mlir::memref::getLinearizedMemRefOffsetAndSize(), getRegisterIndexToTileOffsetMap(), getSplitReductionIvs(), simplifyExprAndOperands(), and mlir::SimpleAffineExprFlattener::visitModExpr().
|
inline |
| MLIRContext * AffineExpr::getContext | ( | ) | const |
Definition at line 31 of file AffineExpr.cpp.
References expr.
Referenced by ceilDiv(), ceilDiv(), mlir::delinearize(), floorDiv(), floorDiv(), mlir::IntegerSet::getContext(), mlir::detail::TileOffsetRangeImpl::getDynamicTileOffsets(), mlir::isBatchMatvec(), mlir::isBatchVecmat(), mlir::isColumnMajorMatmul(), isFunctionOfDim(), isFunctionOfSymbol(), mlir::isMatvec(), mlir::isRowMajorBatchMatmul(), mlir::isRowMajorMatmul(), mlir::isVecmat(), operator%(), operator%(), operator*(), operator*(), operator-(), mlir::affine::reorderOperandsByHoistability(), shiftDims(), shiftSymbols(), mlir::simplifyAffineExpr(), simplifyExprAndOperands(), simplifyMinOrMaxExprWithOperands(), mlir::SimpleAffineExprFlattener::visitModExpr(), and mlir::SimpleAffineExprFlattener::visitMulExpr().
|
inlinestatic |
Definition at line 188 of file AffineExpr.h.
References AffineExpr().
|
inline |
Definition at line 193 of file AffineExpr.h.
References expr.
| AffineExprKind AffineExpr::getKind | ( | ) | const |
Return the classification for this type.
Definition at line 33 of file AffineExpr.cpp.
References expr.
Referenced by checkOperandAffineExprRecursively(), findAffine(), findDepIdxSet(), mlir::sparse_tensor::LoopEmitter::genAffine(), genIndex(), mlir::sparse_tensor::genMapBuffers(), getLargestKnownDivisor(), getTileSizePos(), isFunctionOfDim(), isFunctionOfSymbol(), isInvariantAffine(), isMultipleOf(), llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::AffineExpr, std::remove_const_t< From > >||std::is_base_of_v< mlir::AffineExpr, From > > >::isPossible(), isPureAffine(), isSymbolicOrConstant(), mlir::AsmPrinter::Impl::printAffineExprInternal(), replace(), replaceDimsAndSymbols(), simplifyExprAndOperands(), mlir::AffineExprVisitorBase< SubClass, RetTy >::visit(), mlir::AffineExprVisitor< SubClass, RetTy >::walkPostOrder(), and mlir::AffineExprVisitor< SubClass, LogicalResult >::walkPostOrder().
| int64_t AffineExpr::getLargestKnownDivisor | ( | ) | const |
Returns the greatest known integral divisor of this affine expression.
The result is always positive.
Definition at line 241 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, getKind(), getLargestKnownDivisor(), mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineBinaryOpExpr::getRHS(), mlir::Mod, mlir::Mul, rhs, and mlir::SymbolId.
Referenced by getLargestKnownDivisor(), getLargestKnownDivisor(), and isMultipleOf().
| friend::llvm::hash_code mlir::AffineExpr::hash_value | ( | AffineExpr | arg | ) |
References AffineExpr().
Return true if the affine expression involves AffineDimExpr position.
Definition at line 314 of file AffineExpr.cpp.
References mlir::DimId, expr, mlir::getAffineDimExpr(), getContext(), and getKind().
Referenced by getFirstResultIndexFunctionOf(), mlir::affine::AffineValueMap::isFunctionOf(), mlir::AffineMap::isFunctionOfDim(), and verifyInputMaps().
Return true if the affine expression involves AffineSymbolExpr position.
Definition at line 325 of file AffineExpr.cpp.
References expr, mlir::getAffineSymbolExpr(), getContext(), getKind(), and mlir::SymbolId.
Referenced by mlir::AffineMap::isFunctionOfSymbol().
Return true if the affine expression is a multiple of 'factor'.
Definition at line 281 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, getKind(), getLargestKnownDivisor(), mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineBinaryOpExpr::getRHS(), mlir::Mod, mlir::Mul, and mlir::SymbolId.
| bool AffineExpr::isPureAffine | ( | ) | const |
Returns true if this is a pure affine expression, i.e., multiplication, floordiv, ceildiv, and mod is only allowed w.r.t constants.
Definition at line 210 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, getKind(), mlir::Mod, mlir::Mul, and mlir::SymbolId.
Referenced by mlir::simplifyAffineExpr().
| bool AffineExpr::isSymbolicOrConstant | ( | ) | const |
Returns true if this expression is made out of only symbols and constants, i.e., it does not involve dimensional identifiers.
Returns true if this expression is made out of only symbols and constants (no dimensional identifiers).
Definition at line 186 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, expr, mlir::FloorDiv, getKind(), mlir::Mod, mlir::Mul, and mlir::SymbolId.
|
inlineexplicit |
Definition at line 80 of file AffineExpr.h.
References expr.
|
inline |
Definition at line 82 of file AffineExpr.h.
References expr.
|
inline |
Definition at line 77 of file AffineExpr.h.
References AffineExpr().
|
inline |
Definition at line 79 of file AffineExpr.h.
| AffineExpr AffineExpr::operator% | ( | AffineExpr | other | ) | const |
Definition at line 1067 of file AffineExpr.cpp.
References AffineExpr(), mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), mlir::Mod, and simplifyMod().
| AffineExpr AffineExpr::operator% | ( | uint64_t | v | ) | const |
Definition at line 1064 of file AffineExpr.cpp.
References AffineExpr(), mlir::getAffineConstantExpr(), and getContext().
| AffineExpr AffineExpr::operator* | ( | AffineExpr | other | ) | const |
Definition at line 891 of file AffineExpr.cpp.
References AffineExpr(), mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), lhs, mlir::Mul, rhs, and simplifyMul().
| AffineExpr AffineExpr::operator* | ( | int64_t | v | ) | const |
Definition at line 888 of file AffineExpr.cpp.
References AffineExpr(), mlir::getAffineConstantExpr(), and getContext().
| AffineExpr mlir::AffineExpr::operator+ | ( | AffineExpr | other | ) | const |
References AffineExpr().
| AffineExpr mlir::AffineExpr::operator+ | ( | int64_t | v | ) | const |
References AffineExpr().
| AffineExpr AffineExpr::operator- | ( | ) | const |
Definition at line 903 of file AffineExpr.cpp.
References AffineExpr(), mlir::getAffineConstantExpr(), and getContext().
| AffineExpr AffineExpr::operator- | ( | AffineExpr | other | ) | const |
Definition at line 909 of file AffineExpr.cpp.
References AffineExpr().
| AffineExpr AffineExpr::operator- | ( | int64_t | v | ) | const |
Definition at line 908 of file AffineExpr.cpp.
References AffineExpr().
|
inline |
Definition at line 76 of file AffineExpr.h.
References AffineExpr(), and expr.
| void AffineExpr::print | ( | raw_ostream & | os | ) | const |
Definition at line 4013 of file AsmPrinter.cpp.
References expr, getContext(), mlir::AsmState::getImpl(), and mlir::AsmPrinter::Impl::printAffineExpr().
Referenced by mlir::operator<<().
| AffineExpr AffineExpr::replace | ( | AffineExpr | expr, |
| AffineExpr | replacement ) const |
Sparse replace method.
Sparse replace method. Return the modified expression tree.
Replace expr by replacement and return the modified expression tree.
Definition at line 179 of file AffineExpr.cpp.
References AffineExpr(), expr, replace(), and replacement().
Referenced by replace(), and replaceAffineMinBoundingBoxExpression().
| AffineExpr AffineExpr::replace | ( | const DenseMap< AffineExpr, AffineExpr > & | map | ) | const |
Sparse replace method.
Sparse replace method. Return the modified expression tree.
If *this appears in map replaces it by map[*this] and return the modified expression tree. Otherwise traverse *this and apply replace with map on its subexpressions.
Definition at line 155 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::FloorDiv, mlir::getAffineBinaryOpExpr(), getKind(), lhs, mlir::Mod, mlir::Mul, and rhs.
| AffineExpr AffineExpr::replaceDims | ( | ArrayRef< AffineExpr > | dimReplacements | ) | const |
Dim-only version of replaceDimsAndSymbols.
Definition at line 120 of file AffineExpr.cpp.
References AffineExpr(), and replaceDimsAndSymbols().
Referenced by projectCommonImpl().
| AffineExpr AffineExpr::replaceDimsAndSymbols | ( | ArrayRef< AffineExpr > | dimReplacements, |
| ArrayRef< AffineExpr > | symReplacements ) const |
This method substitutes any uses of dimensions and symbols (e.g.
dim#0 with dimReplacements[0]) and returns the modified expression tree. This is a dense replacement method: a replacement must be specified for every single dim and symbol.
dim#0 with dimReplacements[0]) and returns the modified expression tree.
Definition at line 87 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::getAffineBinaryOpExpr(), getKind(), lhs, mlir::Mod, mlir::Mul, rhs, and mlir::SymbolId.
Referenced by compose(), mlir::ValueBoundsConstraintSet::insert(), replaceDims(), mlir::AffineMap::replaceDimsAndSymbols(), replaceSymbols(), shiftDims(), and shiftSymbols().
| AffineExpr AffineExpr::replaceSymbols | ( | ArrayRef< AffineExpr > | symReplacements | ) | const |
Symbol-only version of replaceDimsAndSymbols.
Definition at line 125 of file AffineExpr.cpp.
References replaceDimsAndSymbols().
Referenced by projectCommonImpl().
| AffineExpr AffineExpr::shiftDims | ( | unsigned | numDims, |
| unsigned | shift, | ||
| unsigned | offset = 0 ) const |
Replace dims[offset ... numDims) by dims[offset + shift ... shift + numDims).
Definition at line 131 of file AffineExpr.cpp.
References AffineExpr(), mlir::getAffineDimExpr(), getContext(), and replaceDimsAndSymbols().
Referenced by mlir::AffineMap::shiftDims().
| AffineExpr AffineExpr::shiftSymbols | ( | unsigned | numSymbols, |
| unsigned | shift, | ||
| unsigned | offset = 0 ) const |
Replace symbols[offset ... numSymbols) by symbols[offset + shift ... shift + numSymbols).
Definition at line 143 of file AffineExpr.cpp.
References AffineExpr(), mlir::getAffineSymbolExpr(), getContext(), and replaceDimsAndSymbols().
Referenced by mlir::AffineMap::shiftSymbols().
|
inline |
Walk all of the AffineExpr's in this expression in postorder.
This allows a lambda walk function that can either return void or a WalkResult. With a WalkResult, interrupting is supported.
Definition at line 117 of file AffineExpr.h.
References walk().
Referenced by getTileSizePos(), isNormalizedMemRefDynamicDim(), walk(), and mlir::AffineMap::walkExprs().
Definition at line 196 of file AffineExpr.h.
Referenced by AffineExpr(), getAsOpaquePointer(), getContext(), getImpl(), getKind(), mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineDimExpr::getPosition(), mlir::AffineBinaryOpExpr::getRHS(), mlir::hash_value(), isFunctionOfDim(), isFunctionOfSymbol(), isSymbolicOrConstant(), operator bool(), operator!(), operator==(), print(), and replace().