MLIR
20.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 |
template<typename U > | |
constexpr bool | isa () const |
template<typename U > | |
U | dyn_cast () const |
template<typename U > | |
U | dyn_cast_or_null () const |
template<typename U > | |
U | cast () const |
MLIRContext * | getContext () const |
AffineExprKind | getKind () const |
Return the classification for this type. More... | |
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. More... | |
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. More... | |
int64_t | getLargestKnownDivisor () const |
Returns the greatest known integral divisor of this affine expression. More... | |
bool | isMultipleOf (int64_t factor) const |
Return true if the affine expression is a multiple of 'factor'. More... | |
bool | isFunctionOfDim (unsigned position) const |
Return true if the affine expression involves AffineDimExpr position . More... | |
bool | isFunctionOfSymbol (unsigned position) const |
Return true if the affine expression involves AffineSymbolExpr position . More... | |
template<typename FnT , typename RetT = detail::walkResultType<FnT>> | |
RetT | walk (FnT &&callback) const |
Walk all of the AffineExpr's in this expression in postorder. More... | |
AffineExpr | replaceDimsAndSymbols (ArrayRef< AffineExpr > dimReplacements, ArrayRef< AffineExpr > symReplacements) const |
This method substitutes any uses of dimensions and symbols (e.g. More... | |
AffineExpr | replaceDims (ArrayRef< AffineExpr > dimReplacements) const |
Dim-only version of replaceDimsAndSymbols. More... | |
AffineExpr | replaceSymbols (ArrayRef< AffineExpr > symReplacements) const |
Symbol-only version of replaceDimsAndSymbols. More... | |
AffineExpr | replace (AffineExpr expr, AffineExpr replacement) const |
Sparse replace method. More... | |
AffineExpr | replace (const DenseMap< AffineExpr, AffineExpr > &map) const |
Sparse replace method. More... | |
AffineExpr | shiftDims (unsigned numDims, unsigned shift, unsigned offset=0) const |
Replace dims[offset ... More... | |
AffineExpr | shiftSymbols (unsigned numSymbols, unsigned shift, unsigned offset=0) const |
Replace symbols[offset ... More... | |
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. More... | |
const void * | getAsOpaquePointer () const |
Methods supporting C API. More... | |
ImplType * | getImpl () const |
Static Public Member Functions | |
static AffineExpr | getFromOpaquePointer (const void *pointer) |
Protected Attributes | |
ImplType * | expr {nullptr} |
Friends | |
::llvm::hash_code | hash_value (AffineExpr arg) |
Make AffineExpr hashable. More... | |
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 getFromOpaquePointer().
|
inline |
Definition at line 73 of file AffineExpr.h.
U mlir::AffineExpr::cast |
Definition at line 311 of file AffineExpr.h.
AffineExpr AffineExpr::ceilDiv | ( | AffineExpr | other | ) | const |
Definition at line 967 of file AffineExpr.cpp.
References mlir::CeilDiv, mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), and simplifyCeilDiv().
AffineExpr AffineExpr::ceilDiv | ( | uint64_t | v | ) | const |
Definition at line 964 of file AffineExpr.cpp.
References mlir::getAffineConstantExpr(), and getContext().
Referenced by mlir::affine::AffineBuilder::ceil(), mlir::getAffineBinaryOpExpr(), mlir::affine::getTripCountMapAndOperands(), getUserTileSizesAndNumThreads(), mlir::affine::normalizeAffineFor(), and mlir::affine::normalizeAffineParallel().
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 1034 of file AffineExpr.cpp.
References mlir::AffineMap::getResults(), and replaceDimsAndSymbols().
Referenced by mlir::AffineMap::compose().
void AffineExpr::dump | ( | ) | const |
Definition at line 3906 of file AsmPrinter.cpp.
U mlir::AffineExpr::dyn_cast |
Definition at line 303 of file AffineExpr.h.
U mlir::AffineExpr::dyn_cast_or_null |
Definition at line 307 of file AffineExpr.h.
AffineExpr AffineExpr::floorDiv | ( | AffineExpr | other | ) | const |
Definition at line 920 of file AffineExpr.cpp.
References mlir::FloorDiv, mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), and simplifyFloorDiv().
AffineExpr AffineExpr::floorDiv | ( | uint64_t | v | ) | const |
Definition at line 917 of file AffineExpr.cpp.
References mlir::getAffineConstantExpr(), and getContext().
Referenced by mlir::affine::coalesceLoops(), common3DIdBuilderFn(), commonLinearIdBuilderFn(), mlir::linalg::computeContinuousTileSizes(), mlir::linalg::computeMultiTileSizes(), mlir::delinearize(), mlir::gpu::WarpDistributionPattern::delinearizeLaneId(), mlir::affine::AffineBuilder::floor(), mlir::getAffineBinaryOpExpr(), mlir::affine::getDivMod(), getExpandedOutputDimFromInputShape(), getIndicesForLoadOrStore(), mlir::nvgpu::getLaneIdAndValueIdToOperandCoord(), mlir::nvgpu::getLaneIdToLdMatrixMatrixCoord(), mlir::memref::getLinearizedMemRefOffsetAndSize(), getRegisterIndexToTileOffsetMap(), simplifyExprAndOperands(), and mlir::SimpleAffineExprFlattener::visitModExpr().
|
inline |
MLIRContext * AffineExpr::getContext | ( | ) | const |
Definition at line 33 of file AffineExpr.cpp.
Referenced by ceilDiv(), mlir::delinearize(), floorDiv(), mlir::AffineMap::get(), mlir::detail::TileOffsetRangeImpl::getDynamicTileOffsets(), mlir::isBatchMatvec(), mlir::isBatchVecmat(), mlir::isMatvec(), isModOfModSubtraction(), mlir::isVecmat(), operator%(), operator*(), operator+(), operator-(), operator==(), mlir::affine::reorderOperandsByHoistability(), simplifyAdd(), mlir::simplifyAffineExpr(), simplifyCeilDiv(), simplifyExprAndOperands(), simplifyFloorDiv(), simplifyMinOrMaxExprWithOperands(), simplifyMod(), simplifyMul(), simplifySemiAffine(), symbolicDivide(), mlir::sparse_tensor::ir_detail::DimLvlExpr::tryGetContext(), mlir::SimpleAffineExprFlattener::visitModExpr(), and mlir::SimpleAffineExprFlattener::visitMulExpr().
|
inlinestatic |
Definition at line 201 of file AffineExpr.h.
References AffineExpr().
|
inline |
Definition at line 206 of file AffineExpr.h.
References expr.
AffineExprKind AffineExpr::getKind | ( | ) | const |
Return the classification for this type.
Definition at line 35 of file AffineExpr.cpp.
Referenced by canSimplifyDivisionBySymbol(), checkOperandAffineExprRecursively(), findAffine(), findDepIdxSet(), mlir::sparse_tensor::LoopEmitter::genAffine(), genIndex(), mlir::sparse_tensor::genMapBuffers(), mlir::sparse_tensor::ir_detail::DimLvlExpr::getAffineKind(), isa(), isInvariantAffine(), isModOfModSubtraction(), 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(), mlir::AsmPrinter::Impl::printAffineExprInternal(), simplifyAdd(), simplifyExprAndOperands(), simplifySemiAffine(), symbolicDivide(), 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 243 of file AffineExpr.cpp.
References mlir::presburger::abs(), mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, getLargestKnownDivisor(), mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineBinaryOpExpr::getRHS(), mlir::Mod, mlir::Mul, and mlir::SymbolId.
Referenced by getLargestKnownDivisor(), getLargestKnownDivisor(), isMultipleOf(), and simplifyMod().
|
constexpr |
Definition at line 292 of file AffineExpr.h.
References mlir::Constant, mlir::DimId, getKind(), mlir::LAST_AFFINE_BINARY_OP, and mlir::SymbolId.
bool AffineExpr::isFunctionOfDim | ( | unsigned | position | ) | const |
Return true if the affine expression involves AffineDimExpr position
.
Definition at line 316 of file AffineExpr.cpp.
References mlir::DimId, mlir::getAffineDimExpr(), and getContext().
Referenced by getFirstResultIndexFunctionOf(), mlir::affine::AffineValueMap::isFunctionOf(), and mlir::AffineMap::isFunctionOfDim().
bool AffineExpr::isFunctionOfSymbol | ( | unsigned | position | ) | const |
Return true if the affine expression involves AffineSymbolExpr position
.
Definition at line 327 of file AffineExpr.cpp.
References mlir::getAffineSymbolExpr(), getContext(), and mlir::SymbolId.
Referenced by mlir::AffineMap::isFunctionOfSymbol().
bool AffineExpr::isMultipleOf | ( | int64_t | factor | ) | const |
Return true if the affine expression is a multiple of 'factor'.
Definition at line 283 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, 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 212 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, 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 188 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::Mod, mlir::Mul, and mlir::SymbolId.
Referenced by simplifyAdd(), and simplifyMul().
|
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.
|
inline |
Definition at line 79 of file AffineExpr.h.
AffineExpr AffineExpr::operator% | ( | AffineExpr | other | ) | const |
Definition at line 1025 of file AffineExpr.cpp.
References mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), mlir::Mod, and simplifyMod().
AffineExpr AffineExpr::operator% | ( | uint64_t | v | ) | const |
Definition at line 1022 of file AffineExpr.cpp.
References mlir::getAffineConstantExpr(), and getContext().
AffineExpr AffineExpr::operator* | ( | AffineExpr | other | ) | const |
Definition at line 851 of file AffineExpr.cpp.
References mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), mlir::Mul, and simplifyMul().
AffineExpr AffineExpr::operator* | ( | int64_t | v | ) | const |
Definition at line 848 of file AffineExpr.cpp.
References mlir::getAffineConstantExpr(), and getContext().
AffineExpr AffineExpr::operator+ | ( | AffineExpr | other | ) | const |
Definition at line 786 of file AffineExpr.cpp.
References mlir::Add, mlir::StorageUniquer::get(), mlir::MLIRContext::getAffineUniquer(), getContext(), and simplifyAdd().
AffineExpr AffineExpr::operator+ | ( | int64_t | v | ) | const |
Definition at line 783 of file AffineExpr.cpp.
References mlir::getAffineConstantExpr(), and getContext().
AffineExpr AffineExpr::operator- | ( | ) | const |
Definition at line 861 of file AffineExpr.cpp.
References mlir::getAffineConstantExpr(), and getContext().
AffineExpr AffineExpr::operator- | ( | AffineExpr | other | ) | const |
Definition at line 867 of file AffineExpr.cpp.
AffineExpr AffineExpr::operator- | ( | int64_t | v | ) | const |
Definition at line 866 of file AffineExpr.cpp.
|
inline |
Definition at line 76 of file AffineExpr.h.
References expr.
bool AffineExpr::operator== | ( | int64_t | v | ) | const |
Definition at line 637 of file AffineExpr.cpp.
References mlir::getAffineConstantExpr(), and getContext().
void AffineExpr::print | ( | raw_ostream & | os | ) | const |
Definition at line 3897 of file AsmPrinter.cpp.
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 181 of file AffineExpr.cpp.
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 157 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::FloorDiv, mlir::getAffineBinaryOpExpr(), mlir::Mod, and mlir::Mul.
AffineExpr AffineExpr::replaceDims | ( | ArrayRef< AffineExpr > | dimReplacements | ) | const |
Dim-only version of replaceDimsAndSymbols.
Definition at line 122 of file AffineExpr.cpp.
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 89 of file AffineExpr.cpp.
References mlir::Add, mlir::CeilDiv, mlir::Constant, mlir::DimId, mlir::FloorDiv, mlir::getAffineBinaryOpExpr(), mlir::Mod, mlir::Mul, and mlir::SymbolId.
Referenced by compose(), mlir::ValueBoundsConstraintSet::insert(), and mlir::AffineMap::replaceDimsAndSymbols().
AffineExpr AffineExpr::replaceSymbols | ( | ArrayRef< AffineExpr > | symReplacements | ) | const |
Symbol-only version of replaceDimsAndSymbols.
Definition at line 127 of file AffineExpr.cpp.
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 133 of file AffineExpr.cpp.
References mlir::getAffineDimExpr(), and getContext().
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 145 of file AffineExpr.cpp.
References mlir::getAffineSymbolExpr(), and getContext().
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 130 of file AffineExpr.h.
Referenced by isNormalizedMemRefDynamicDim(), and mlir::AffineMap::walkExprs().
|
friend |
Make AffineExpr hashable.
Definition at line 260 of file AffineExpr.h.
|
protected |
Definition at line 209 of file AffineExpr.h.
Referenced by getAsOpaquePointer(), getImpl(), mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineDimExpr::getPosition(), mlir::AffineSymbolExpr::getPosition(), mlir::AffineBinaryOpExpr::getRHS(), mlir::AffineConstantExpr::getValue(), operator bool(), operator!(), and operator==().