MLIR
20.0.0git
|
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/ShapedOpInterfaces.h"
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallVectorExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include <numeric>
#include <optional>
#include "mlir/Dialect/Affine/IR/AffineOpsDialect.cpp.inc"
#include "mlir/Dialect/Affine/IR/AffineOps.cpp.inc"
Go to the source code of this file.
Classes | |
struct | DeduplicateAffineMinMaxExpressions< T > |
Remove duplicated expressions in affine min/max ops. More... | |
struct | MergeAffineMinMaxOp< T > |
Merge an affine min/max op to its consumers if its consumer is also an affine min/max op. More... | |
struct | CanonicalizeAffineMinMaxOpExprAndTermOrder< T > |
Canonicalize the affine map result expression order of an affine min/max operation. More... | |
struct | CanonicalizeSingleResultAffineMinMaxOp< T > |
Macros | |
#define | DEBUG_TYPE "affine-ops" |
#define | GET_OP_LIST |
#define | GET_OP_CLASSES |
Functions | |
static bool | remainsLegalAfterInline (Value value, Region *src, Region *dest, const IRMapping &mapping, function_ref< bool(Value, Region *)> legalityCheck) |
Checks if value known to be a legal affine dimension or symbol in src region remains legal if the operation that uses it is inlined into dest with the given value mapping. More... | |
static bool | remainsLegalAfterInline (ValueRange values, Region *src, Region *dest, const IRMapping &mapping, function_ref< bool(Value, Region *)> legalityCheck) |
Checks if all values known to be legal affine dimensions or symbols in src remain so if their respective users are inlined into dest . More... | |
template<typename OpTy > | |
static bool | remainsLegalAfterInline (OpTy op, Region *src, Region *dest, const IRMapping &mapping) |
Checks if an affine read or write operation remains legal after inlining from src to dest . More... | |
template<> | |
bool LLVM_ATTRIBUTE_UNUSED | remainsLegalAfterInline (AffineApplyOp op, Region *src, Region *dest, const IRMapping &mapping) |
Checks if an affine apply operation remains legal after inlining from src to dest . More... | |
template<typename AnyMemRefDefOp > | |
static bool | isMemRefSizeValidSymbol (AnyMemRefDefOp memrefDefOp, unsigned index, Region *region) |
Returns true if the 'index' dimension of the memref defined by memrefDefOp is a statically shaped one or defined using a valid symbol for region . More... | |
static bool | isDimOpValidSymbol (ShapedDimOpInterface dimOp, Region *region) |
Returns true if the result of the dim op is a valid symbol for region . More... | |
static bool | isValidAffineIndexOperand (Value value, Region *region) |
static void | printDimAndSymbolList (Operation::operand_iterator begin, Operation::operand_iterator end, unsigned numDims, OpAsmPrinter &printer) |
Prints dimension and symbol list. More... | |
template<typename OpTy > | |
static LogicalResult | verifyDimAndSymbolIdentifiers (OpTy &op, Operation::operand_range operands, unsigned numDims) |
Utility function to verify that a set of operands are valid dimension and symbol identifiers. More... | |
static int64_t | getLargestKnownDivisor (AffineExpr e, ArrayRef< Value > operands) |
Returns the largest known divisor of e . More... | |
static bool | isNonNegativeBoundedBy (AffineExpr e, ArrayRef< Value > operands, int64_t k) |
Check if e is known to be: 0 <= e < k . More... | |
static bool | isQTimesDPlusR (AffineExpr e, ArrayRef< Value > operands, int64_t &div, AffineExpr "ientTimesDiv, AffineExpr &rem) |
Check if expression e is of the form d*e_1 + e_2 where 0 <= e_2 < d. More... | |
static std::optional< int64_t > | getLowerBound (Value iv) |
Gets the constant lower bound on an iv . More... | |
static std::optional< int64_t > | getUpperBound (Value iv) |
Gets the constant upper bound on an affine.for iv . More... | |
static std::optional< int64_t > | getUpperBound (AffineExpr expr, unsigned numDims, unsigned numSymbols, ArrayRef< Value > operands) |
Determine a constant upper bound for expr if one exists while exploiting values in operands . More... | |
static std::optional< int64_t > | getLowerBound (AffineExpr expr, unsigned numDims, unsigned numSymbols, ArrayRef< Value > operands) |
Determine a constant lower bound for expr if one exists while exploiting values in operands . More... | |
static void | simplifyExprAndOperands (AffineExpr &expr, unsigned numDims, unsigned numSymbols, ArrayRef< Value > operands) |
Simplify expr while exploiting information from the values in operands . More... | |
static void | simplifyMinOrMaxExprWithOperands (AffineMap &map, ArrayRef< Value > operands, bool isMax) |
Simplify the expressions in map while making use of lower or upper bounds of its operands. More... | |
static void LLVM_ATTRIBUTE_UNUSED | simplifyMapWithOperands (AffineMap &map, ArrayRef< Value > operands) |
Simplify the map while exploiting information on the values in operands . More... | |
static LogicalResult | replaceDimOrSym (AffineMap *map, unsigned dimOrSymbolPosition, SmallVectorImpl< Value > &dims, SmallVectorImpl< Value > &syms) |
Replace all occurrences of AffineExpr at position pos in map by the defining AffineApplyOp expression and operands. More... | |
static void | composeAffineMapAndOperands (AffineMap *map, SmallVectorImpl< Value > *operands) |
Iterate over operands and fold away all those produced by an AffineApplyOp iteratively. More... | |
static void | composeMultiResultAffineMap (AffineMap &map, SmallVectorImpl< Value > &operands) |
Composes the given affine map with the given list of operands, pulling in the maps from any affine.apply operations that supply the operands. More... | |
template<typename OpTy > | |
static OpTy | makeComposedMinMax (OpBuilder &b, Location loc, AffineMap map, ArrayRef< OpFoldResult > operands) |
template<typename OpTy > | |
static OpFoldResult | makeComposedFoldedMinMax (OpBuilder &b, Location loc, AffineMap map, ArrayRef< OpFoldResult > operands) |
template<class MapOrSet > | |
static void | canonicalizePromotedSymbols (MapOrSet *mapOrSet, SmallVectorImpl< Value > *operands) |
template<class MapOrSet > | |
static void | canonicalizeMapOrSetAndOperands (MapOrSet *mapOrSet, SmallVectorImpl< Value > *operands) |
static ParseResult | parseBound (bool isLower, OperationState &result, OpAsmParser &p) |
Parse a for operation loop bounds. More... | |
static void | printBound (AffineMapAttr boundMap, Operation::operand_range boundOperands, const char *prefix, OpAsmPrinter &p) |
static LogicalResult | foldLoopBounds (AffineForOp forOp) |
Fold the constant bounds of a loop. More... | |
static LogicalResult | canonicalizeLoopBounds (AffineForOp forOp) |
Canonicalize the bounds of the given loop. More... | |
static bool | hasTrivialZeroTripCount (AffineForOp op) |
Returns true if the affine.for has zero iterations in trivial cases. More... | |
template<typename BoundListTy , typename LoopCreatorTy > | |
static void | buildAffineLoopNestImpl (OpBuilder &builder, Location loc, BoundListTy lbs, BoundListTy ubs, ArrayRef< int64_t > steps, function_ref< void(OpBuilder &, Location, ValueRange)> bodyBuilderFn, LoopCreatorTy &&loopCreatorFn) |
Builds an affine loop nest, using "loopCreatorFn" to create individual loop operations. More... | |
static AffineForOp | buildAffineLoopFromConstants (OpBuilder &builder, Location loc, int64_t lb, int64_t ub, int64_t step, AffineForOp::BodyBuilderFn bodyBuilderFn) |
Creates an affine loop from the bounds known to be constants. More... | |
static AffineForOp | buildAffineLoopFromValues (OpBuilder &builder, Location loc, Value lb, Value ub, int64_t step, AffineForOp::BodyBuilderFn bodyBuilderFn) |
Creates an affine loop from the bounds that may or may not be constants. More... | |
static void | composeSetAndOperands (IntegerSet &set, SmallVectorImpl< Value > &operands) |
Compose any affine.apply ops feeding into operands of the integer set set by composing the maps of such affine.apply ops with the integer set constraints. More... | |
static LogicalResult | verifyMemoryOpIndexing (Operation *op, AffineMapAttr mapAttr, Operation::operand_range mapOperands, MemRefType memrefType, unsigned numIndexOperands) |
Verify common indexing invariants of affine.load, affine.store, affine.vector_load and affine.vector_store. More... | |
template<typename T > | |
static LogicalResult | verifyAffineMinMaxOp (T op) |
template<typename T > | |
static void | printAffineMinMaxOp (OpAsmPrinter &p, T op) |
template<typename T > | |
static ParseResult | parseAffineMinMaxOp (OpAsmParser &parser, OperationState &result) |
template<typename T > | |
static OpFoldResult | foldMinMaxOp (T op, ArrayRef< Attribute > operands) |
Fold an affine min or max operation with the given operands. More... | |
static LogicalResult | canonicalizeMapExprAndTermOrder (AffineMap &map) |
Canonicalize the result expression order of an affine map and return success if the order changed. More... | |
static bool | isResultTypeMatchAtomicRMWKind (Type resultType, arith::AtomicRMWKind op) |
static LogicalResult | canonicalizeLoopBounds (AffineParallelOp op) |
Canonicalize the bounds of the given loop. More... | |
static void | printMinMaxBound (OpAsmPrinter &p, AffineMapAttr mapAttr, DenseIntElementsAttr group, ValueRange operands, StringRef keyword) |
Prints a lower(upper) bound of an affine parallel loop with max(min) conditions in it. More... | |
static ParseResult | deduplicateAndResolveOperands (OpAsmParser &parser, ArrayRef< SmallVector< OpAsmParser::UnresolvedOperand >> operands, SmallVectorImpl< Value > &uniqueOperands, SmallVectorImpl< AffineExpr > &replacements, AffineExprKind kind) |
Given a list of lists of parsed operands, populates uniqueOperands with unique operands. More... | |
static ParseResult | parseAffineMapWithMinMax (OpAsmParser &parser, OperationState &result, MinMaxKind kind) |
Parses an affine map that can contain a min/max for groups of its results, e.g., max(expr-1, expr-2), expr-3, max(expr-4, expr-5, expr-6). More... | |
static LogicalResult | verifyVectorMemoryOp (Operation *op, MemRefType memrefType, VectorType vectorType) |
Verify common invariants of affine.vector_load and affine.vector_store. More... | |
static std::optional< SmallVector< int64_t > > | foldCstValueToCstAttrBasis (ArrayRef< OpFoldResult > mixedBasis, MutableOperandRange mutableDynamicBasis, ArrayRef< Attribute > dynamicBasis) |
Given mixed basis of affine.delinearize_index/linearize_index replace constant SSA values with the constant integer value and return the new static basis. More... | |
#define DEBUG_TYPE "affine-ops" |
Definition at line 40 of file AffineOps.cpp.
#define GET_OP_CLASSES |
Definition at line 5107 of file AffineOps.cpp.
#define GET_OP_LIST |
|
static |
Creates an affine loop from the bounds known to be constants.
Definition at line 2653 of file AffineOps.cpp.
References mlir::OpBuilder::create().
Referenced by buildAffineLoopFromValues(), and mlir::affine::buildAffineLoopNest().
|
static |
Creates an affine loop from the bounds that may or may not be constants.
Definition at line 2662 of file AffineOps.cpp.
References buildAffineLoopFromConstants(), mlir::OpBuilder::create(), mlir::getConstantIntValue(), and mlir::Builder::getDimIdentityMap().
Referenced by mlir::affine::buildAffineLoopNest().
|
static |
Builds an affine loop nest, using "loopCreatorFn" to create individual loop operations.
Definition at line 2612 of file AffineOps.cpp.
References mlir::OpBuilder::create(), and mlir::OpBuilder::setInsertionPointToStart().
Referenced by mlir::affine::buildAffineLoopNest().
|
static |
Canonicalize the bounds of the given loop.
Definition at line 2231 of file AffineOps.cpp.
References mlir::affine::canonicalizeMapAndOperands(), composeAffineMapAndOperands(), mlir::removeDuplicateExprs(), and simplifyMinOrMaxExprWithOperands().
|
static |
Canonicalize the bounds of the given loop.
Definition at line 3967 of file AffineOps.cpp.
References mlir::affine::AffineValueMap::canonicalize(), mlir::affine::AffineValueMap::getAffineMap(), and mlir::affine::AffineValueMap::getOperands().
|
static |
Canonicalize the result expression order of an affine map and return success if the order changed.
The function flattens the map's affine expressions to coefficient arrays and sorts them in lexicographic order. A coefficient array contains a multiplier for every dimension/symbol and a constant term. The canonicalization fails if a result expression is not pure or if the flattening requires local variables that, unlike dimensions and symbols, have no global order.
Definition at line 3425 of file AffineOps.cpp.
References mlir::AffineMap::get(), mlir::AffineMap::getContext(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), mlir::AffineMap::getResult(), mlir::AffineMap::getResults(), mlir::SimpleAffineExprFlattener::operandExprStack, and mlir::AffineExprVisitor< SubClass, RetTy >::walkPostOrder().
Referenced by CanonicalizeAffineMinMaxOpExprAndTermOrder< T >::matchAndRewrite().
|
static |
Definition at line 1359 of file AffineOps.cpp.
References mlir::getAffineConstantExpr(), mlir::getAffineDimExpr(), mlir::getAffineSymbolExpr(), mlir::m_Constant(), and mlir::matchPattern().
|
static |
Definition at line 1316 of file AffineOps.cpp.
References mlir::getAffineDimExpr(), mlir::getAffineSymbolExpr(), and mlir::affine::isValidSymbol().
|
static |
Iterate over operands
and fold away all those produced by an AffineApplyOp iteratively.
Perform canonicalization of map and operands as well as AffineMap simplification. map
and operands
are mutated in place.
Definition at line 1072 of file AffineOps.cpp.
References mlir::affine::canonicalizeMapAndOperands(), mlir::changed, mlir::detail::enumerate(), mlir::getAffineConstantExpr(), mlir::getAffineDimExpr(), mlir::getAffineSymbolExpr(), mlir::AffineMap::getContext(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::isFunctionOfDim(), mlir::AffineMap::isFunctionOfSymbol(), replaceDimOrSym(), mlir::AffineMap::replaceDimsAndSymbols(), and mlir::simplifyAffineMap().
Referenced by mlir::affine::AffineValueMap::canonicalize(), canonicalizeLoopBounds(), composeSetAndOperands(), mlir::affine::fullyComposeAffineMapAndOperands(), and mlir::affine::makeComposedAffineApply().
|
static |
Composes the given affine map with the given list of operands, pulling in the maps from any affine.apply operations that supply the operands.
Definition at line 1165 of file AffineOps.cpp.
References mlir::affine::canonicalizeMapAndOperands(), mlir::affine::fullyComposeAffineMapAndOperands(), mlir::AffineMap::get(), mlir::AffineMap::getContext(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getResult(), mlir::AffineMap::getSubMap(), mlir::AffineMap::shiftDims(), and mlir::AffineMap::shiftSymbols().
Referenced by makeComposedMinMax().
|
static |
Compose any affine.apply ops feeding into operands
of the integer set set
by composing the maps of such affine.apply ops with the integer set constraints.
Definition at line 2938 of file AffineOps.cpp.
References composeAffineMapAndOperands(), mlir::AffineMap::get(), mlir::IntegerSet::get(), mlir::IntegerSet::getConstraints(), mlir::IntegerSet::getContext(), mlir::Value::getDefiningOp(), mlir::IntegerSet::getEqFlags(), mlir::AffineMap::getNumDims(), mlir::IntegerSet::getNumDims(), mlir::AffineMap::getNumSymbols(), mlir::IntegerSet::getNumSymbols(), and mlir::AffineMap::getResults().
|
static |
Given a list of lists of parsed operands, populates uniqueOperands
with unique operands.
Also populates replacements with affine expressions of
kindthat can be used to update affine maps previously accepting a
operandsto accept
uniqueOperands` instead.
Definition at line 4064 of file AffineOps.cpp.
References mlir::DimId, mlir::getAffineDimExpr(), mlir::getAffineSymbolExpr(), mlir::AsmParser::getBuilder(), mlir::AsmParser::getContext(), mlir::Builder::getIndexType(), mlir::OpAsmParser::resolveOperands(), and mlir::SymbolId.
Referenced by parseAffineMapWithMinMax().
|
static |
Given mixed basis of affine.delinearize_index/linearize_index replace constant SSA values with the constant integer value and return the new static basis.
In case no such candidate for replacement exists, this utility returns std::nullopt.
Definition at line 4577 of file AffineOps.cpp.
References mlir::MutableOperandRange::erase(), and mlir::getConstantIntValue().
|
static |
Fold the constant bounds of a loop.
Definition at line 2185 of file AffineOps.cpp.
References mlir::AffineMap::constantFold(), mlir::AffineMap::getNumResults(), mlir::m_Constant(), and mlir::matchPattern().
|
static |
Fold an affine min or max operation with the given operands.
The operand list may contain nulls, which are interpreted as the operand not being a constant.
Definition at line 3262 of file AffineOps.cpp.
References mlir::get().
|
static |
Returns the largest known divisor of e
.
Exploits information from the values in operands
.
Definition at line 624 of file AffineOps.cpp.
References mlir::affine::getForInductionVarOwner(), and mlir::AffineExpr::getLargestKnownDivisor().
Referenced by isQTimesDPlusR(), and simplifyExprAndOperands().
|
static |
Determine a constant lower bound for expr
if one exists while exploiting values in operands
.
Note that the upper bound is an inclusive one. expr
is guaranteed to be less than or equal to it.
Definition at line 763 of file AffineOps.cpp.
References mlir::getBoundForAffineExpr(), getLowerBound(), and getUpperBound().
|
static |
Gets the constant lower bound on an iv
.
Definition at line 714 of file AffineOps.cpp.
References mlir::affine::getForInductionVarOwner().
Referenced by getLowerBound(), getUpperBound(), simplifyExprAndOperands(), and simplifyMinOrMaxExprWithOperands().
|
static |
Determine a constant upper bound for expr
if one exists while exploiting values in operands
.
Note that the upper bound is an inclusive one. expr
is guaranteed to be less than or equal to it.
Definition at line 740 of file AffineOps.cpp.
References mlir::getBoundForAffineExpr(), getLowerBound(), and getUpperBound().
|
static |
Gets the constant upper bound on an affine.for iv
.
Definition at line 722 of file AffineOps.cpp.
References mlir::affine::getForInductionVarOwner().
Referenced by getLowerBound(), getUpperBound(), simplifyExprAndOperands(), and simplifyMinOrMaxExprWithOperands().
|
static |
Returns true if the affine.for has zero iterations in trivial cases.
Definition at line 2373 of file AffineOps.cpp.
|
static |
Returns true if the result of the dim op is a valid symbol for region
.
Definition at line 348 of file AffineOps.cpp.
References mlir::getConstantIntValue(), isMemRefSizeValidSymbol(), and mlir::affine::isTopLevelValue().
Referenced by mlir::affine::isValidSymbol().
|
static |
Returns true if the 'index' dimension of the memref
defined by memrefDefOp
is a statically shaped one or defined using a valid symbol for region
.
Definition at line 329 of file AffineOps.cpp.
References mlir::affine::isValidSymbol().
Referenced by isDimOpValidSymbol().
|
static |
Check if e
is known to be: 0 <= e
< k
.
Handles the simple cases of e
being an affine dim expression or a constant.
Definition at line 662 of file AffineOps.cpp.
References mlir::affine::getForInductionVarOwner().
Referenced by isQTimesDPlusR(), and simplifyExprAndOperands().
|
static |
Check if expression e
is of the form d*e_1 + e_2 where 0 <= e_2 < d.
Set div
to d
, quotientTimesDiv
to e_1 and rem
to e_2 if the expression is in that form.
Definition at line 690 of file AffineOps.cpp.
References mlir::Add, getLargestKnownDivisor(), and isNonNegativeBoundedBy().
Referenced by simplifyExprAndOperands().
|
static |
Definition at line 3859 of file AffineOps.cpp.
Definition at line 466 of file AffineOps.cpp.
References mlir::affine::isValidDim(), and mlir::affine::isValidSymbol().
Referenced by mlir::affine::AffineDmaStartOp::verifyInvariantsImpl(), mlir::affine::AffineDmaWaitOp::verifyInvariantsImpl(), and verifyMemoryOpIndexing().
|
static |
Definition at line 1267 of file AffineOps.cpp.
References mlir::Builder::getContext(), mlir::OpBuilder::getInsertionBlock(), mlir::OpBuilder::getInsertionPoint(), mlir::OpBuilder::getListener(), mlir::m_Constant(), mlir::matchPattern(), and mlir::OpBuilder::setInsertionPoint().
|
static |
Definition at line 1252 of file AffineOps.cpp.
References composeMultiResultAffineMap(), mlir::OpBuilder::create(), mlir::foldAttributesIntoMap(), and mlir::Builder::getIndexType().
|
static |
Parses an affine map that can contain a min/max for groups of its results, e.g., max(expr-1, expr-2), expr-3, max(expr-4, expr-5, expr-6).
Populates result
attributes with the map (flat list of expressions) and the grouping (list of integers that specify how many expressions to put into each min/max) attributes. Deduplicates repeated operands.
parallel-bound ::= (
parallel-group-list )
parallel-group-list ::= parallel-group (,
parallel-group-list)? parallel-group ::= simple-group | min-max-group simple-group ::= expr-of-ssa-ids min-max-group ::= ( min
| max
) (
expr-of-ssa-ids-list )
expr-of-ssa-ids-list ::= expr-of-ssa-ids (,
expr-of-ssa-id-list)?
Examples: (%0, min(%1 + %2, %3), %4, min(%5 floordiv 32, %6)) (%0, max(%1 - 2 * %2))
Definition at line 4111 of file AffineOps.cpp.
References mlir::OperationState::addAttribute(), mlir::OperationState::attributes, deduplicateAndResolveOperands(), mlir::DimId, mlir::NamedAttrList::erase(), mlir::AffineMap::get(), mlir::get(), mlir::AsmParser::getBuilder(), mlir::AsmParser::getContext(), mlir::Builder::getEmptyAffineMap(), mlir::Builder::getI32TensorAttr(), mlir::OperationState::operands, mlir::AsmParser::Paren, mlir::OpAsmParser::parseAffineExprOfSSAIds(), mlir::OpAsmParser::parseAffineMapOfSSAIds(), mlir::AsmParser::parseCommaSeparatedList(), mlir::AsmParser::parseLParen(), mlir::AsmParser::parseOptionalKeyword(), mlir::AsmParser::parseOptionalRParen(), mlir::AsmParser::parseRParen(), and mlir::SymbolId.
|
static |
Definition at line 3239 of file AffineOps.cpp.
References mlir::AsmParser::addTypeToList(), mlir::OperationState::attributes, mlir::AsmParser::getBuilder(), mlir::Builder::getIndexType(), mlir::OperationState::operands, mlir::AsmParser::OptionalSquare, mlir::AsmParser::Paren, mlir::AsmParser::parseAttribute(), mlir::OpAsmParser::parseOperandList(), mlir::AsmParser::parseOptionalAttrDict(), mlir::OpAsmParser::resolveOperands(), and mlir::OperationState::types.
|
static |
Parse a for operation loop bounds.
Definition at line 1920 of file AffineOps.cpp.
References mlir::OperationState::addAttribute(), mlir::OperationState::attributes, mlir::AsmParser::emitError(), mlir::get(), mlir::AsmParser::getBuilder(), mlir::Builder::getConstantAffineMap(), mlir::AsmParser::getCurrentLocation(), mlir::Builder::getIndexType(), mlir::AsmParser::getNameLoc(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), mlir::Builder::getSymbolIdentityMap(), mlir::OperationState::name, mlir::OperationState::operands, mlir::AsmParser::parseAttribute(), mlir::affine::parseDimAndSymbolList(), mlir::OpAsmParser::parseOperandList(), mlir::AsmParser::parseOptionalKeyword(), mlir::NamedAttrList::pop_back(), and mlir::OpAsmParser::resolveOperand().
|
static |
Definition at line 3226 of file AffineOps.cpp.
References mlir::OpAsmPrinter::printOptionalAttrDict().
|
static |
Definition at line 2095 of file AffineOps.cpp.
References mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), mlir::AffineMap::getResult(), printDimAndSymbolList(), and mlir::OpAsmPrinter::printOperand().
|
static |
Prints dimension and symbol list.
Definition at line 471 of file AffineOps.cpp.
Referenced by printBound().
|
static |
Prints a lower(upper) bound of an affine parallel loop with max(min) conditions in it.
mapAttr
is a flat list of affine expressions and group
identifies which of the those expressions form max/min groups. operands
are the SSA values of dimensions and symbols and keyword
is either "min" or "max".
Definition at line 3996 of file AffineOps.cpp.
References mlir::get(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getResult(), mlir::AffineMap::getSliceMap(), mlir::OpAsmPrinter::printAffineExprOfSSAIds(), and mlir::OpAsmPrinter::printAffineMapOfSSAIds().
bool LLVM_ATTRIBUTE_UNUSED remainsLegalAfterInline | ( | AffineApplyOp | op, |
Region * | src, | ||
Region * | dest, | ||
const IRMapping & | mapping | ||
) |
Checks if an affine apply operation remains legal after inlining from src
to dest
.
Definition at line 126 of file AffineOps.cpp.
References mlir::affine::isValidDim(), mlir::affine::isValidSymbol(), and remainsLegalAfterInline().
|
static |
Checks if an affine read or write operation remains legal after inlining from src
to dest
.
Definition at line 100 of file AffineOps.cpp.
References mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumSymbols(), mlir::affine::isValidDim(), mlir::affine::isValidSymbol(), and remainsLegalAfterInline().
|
static |
Checks if value
known to be a legal affine dimension or symbol in src
region remains legal if the operation that uses it is inlined into dest
with the given value mapping.
legalityCheck
is either isValidDim
or isValidSymbol
, depending on the value being required to remain a valid dimension or symbol.
Definition at line 60 of file AffineOps.cpp.
References mlir::Value::getDefiningOp(), mlir::affine::isTopLevelValue(), mlir::IRMapping::lookup(), mlir::m_Constant(), and mlir::matchPattern().
Referenced by remainsLegalAfterInline().
|
static |
Checks if all values known to be legal affine dimensions or symbols in src
remain so if their respective users are inlined into dest
.
Definition at line 89 of file AffineOps.cpp.
References remainsLegalAfterInline().
|
static |
Replace all occurrences of AffineExpr at position pos
in map
by the defining AffineApplyOp expression and operands.
When dimOrSymbolPosition < dims.size()
, AffineDimExpr@[pos] is replaced. When dimOrSymbolPosition >= dims.size()
, AffineSymbolExpr@[pos - dims.size()] is replaced. Mutate map
,dims
and syms
in place as follows:
dims
and syms
are only appended to.map
dim and symbols are gradually shifted to higher positions.dim
and sym
entries are replaced by nullptr This avoids the need for any bookkeeping. Definition at line 1024 of file AffineOps.cpp.
References mlir::affine::canonicalizeMapAndOperands(), mlir::getAffineDimExpr(), mlir::getAffineSymbolExpr(), mlir::AffineMap::getContext(), mlir::Value::getDefiningOp(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), mlir::AffineMap::getResult(), mlir::AffineMap::replace(), mlir::AffineMap::shiftDims(), and mlir::AffineMap::shiftSymbols().
Referenced by composeAffineMapAndOperands().
|
static |
Simplify expr
while exploiting information from the values in operands
.
Definition at line 787 of file AffineOps.cpp.
References mlir::CeilDiv, mlir::FloorDiv, mlir::AffineExpr::floorDiv(), mlir::getAffineBinaryOpExpr(), mlir::getAffineConstantExpr(), mlir::AffineExpr::getContext(), mlir::AffineExpr::getKind(), getLargestKnownDivisor(), getLowerBound(), getUpperBound(), isNonNegativeBoundedBy(), isQTimesDPlusR(), and mlir::Mod.
Referenced by simplifyMapWithOperands().
|
static |
Simplify the map while exploiting information on the values in operands
.
Definition at line 1001 of file AffineOps.cpp.
References mlir::AffineMap::get(), mlir::AffineMap::getContext(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumInputs(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), mlir::AffineMap::getResults(), and simplifyExprAndOperands().
|
static |
Simplify the expressions in map
while making use of lower or upper bounds of its operands.
If isMax
is true, the map is to be treated as a max of its result expressions, and min otherwise. Eg: min (d0, d1) -> (8, 4 * d0 + d1) can be simplified to (8) if the operands are respectively lower bounded by 2 and 0 (the second expression can't be lower than 8).
Definition at line 890 of file AffineOps.cpp.
References mlir::detail::enumerate(), mlir::AffineMap::get(), mlir::getAffineConstantExpr(), mlir::getBoundForAffineExpr(), mlir::AffineExpr::getContext(), mlir::AffineMap::getContext(), getLowerBound(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), mlir::AffineMap::getResults(), and getUpperBound().
Referenced by canonicalizeLoopBounds().
|
static |
Definition at line 3213 of file AffineOps.cpp.
|
static |
Utility function to verify that a set of operands are valid dimension and symbol identifiers.
The operands should be laid out such that the dimension operands are before the symbol operands. This function returns failure if there was an invalid operand. An operation is provided to emit any necessary errors.
Definition at line 503 of file AffineOps.cpp.
References mlir::affine::getAffineScope(), mlir::affine::isValidDim(), and mlir::affine::isValidSymbol().
|
static |
Verify common indexing invariants of affine.load, affine.store, affine.vector_load and affine.vector_store.
Definition at line 3044 of file AffineOps.cpp.
References mlir::Operation::emitOpError(), mlir::affine::getAffineScope(), mlir::AffineMap::getNumInputs(), mlir::AffineMap::getNumResults(), and isValidAffineIndexOperand().
|
static |
Verify common invariants of affine.vector_load and affine.vector_store.
Definition at line 4398 of file AffineOps.cpp.
References mlir::Operation::emitOpError().