MLIR
15.0.0git
|
Public Member Functions | |
ConversionPatternRewriterImpl (PatternRewriter &rewriter) | |
void | discardRewrites () |
Cleanup and destroy any generated rewrite operations. More... | |
void | applyRewrites () |
Apply all requested operation rewrites. More... | |
RewriterState | getCurrentState () |
Return the current state of the rewriter. More... | |
void | resetState (RewriterState state) |
Reset the state of the rewriter to a previously saved point. More... | |
void | eraseDanglingBlocks () |
Erase any blocks that were unlinked from their regions and stored in block actions. More... | |
void | undoBlockActions (unsigned numActionsToKeep=0) |
Undo the block actions (motions, splits) one by one in reverse order until "numActionsToKeep" actions remains. More... | |
LogicalResult | remapValues (StringRef valueDiagTag, Optional< Location > inputLoc, PatternRewriter &rewriter, ValueRange values, SmallVectorImpl< Value > &remapped) |
Remap the given values to those with potentially different types. More... | |
bool | isOpIgnored (Operation *op) const |
Returns true if the given operation is ignored, and does not need to be converted. More... | |
void | markNestedOpsIgnored (Operation *op) |
Recursively marks the nested operations under 'op' as ignored. More... | |
FailureOr< Block * > | convertBlockSignature (Block *block, TypeConverter *converter, TypeConverter::SignatureConversion *conversion=nullptr) |
Convert the signature of the given block. More... | |
Block * | applySignatureConversion (Region *region, TypeConverter::SignatureConversion &conversion, TypeConverter *converter) |
Apply a signature conversion on the given region, using converter for materializations if not null. More... | |
FailureOr< Block * > | convertRegionTypes (Region *region, TypeConverter &converter, TypeConverter::SignatureConversion *entryConversion) |
Convert the types of block arguments within the given region. More... | |
LogicalResult | convertNonEntryRegionTypes (Region *region, TypeConverter &converter, ArrayRef< TypeConverter::SignatureConversion > blockConversions={}) |
Convert the types of non-entry block arguments within the given region. More... | |
void | notifyOpReplaced (Operation *op, ValueRange newValues) |
PatternRewriter hook for replacing the results of an operation. More... | |
void | notifyBlockIsBeingErased (Block *block) |
Notifies that a block is about to be erased. More... | |
void | notifyCreatedBlock (Block *block) |
Notifies that a block was created. More... | |
void | notifySplitBlock (Block *block, Block *continuation) |
Notifies that a block was split. More... | |
void | notifyBlocksBeingMerged (Block *block, Block *srcBlock) |
Notifies that block is being merged with srcBlock . More... | |
void | notifyRegionIsBeingInlinedBefore (Region ®ion, Region &parent, Region::iterator before) |
Notifies that the blocks of a region are about to be moved. More... | |
void | notifyRegionWasClonedBefore (iterator_range< Region::iterator > &blocks, Location origRegionLoc) |
Notifies that the blocks of a region were cloned into another. More... | |
LogicalResult | notifyMatchFailure (Location loc, function_ref< void(Diagnostic &)> reasonCallback) |
Notifies that a pattern match failed for the given reason. More... | |
Public Attributes | |
ConversionValueMapping | mapping |
ArgConverter | argConverter |
Utility used to convert block arguments. More... | |
SmallVector< Operation * > | createdOps |
Ordered vector of all of the newly created operations during conversion. More... | |
SmallVector< UnresolvedMaterialization > | unresolvedMaterializations |
Ordered vector of all unresolved type conversion materializations during conversion. More... | |
llvm::MapVector< Operation *, OpReplacement > | replacements |
Ordered map of requested operation replacements. More... | |
SmallVector< BlockArgument, 4 > | argReplacements |
Ordered vector of any requested block argument replacements. More... | |
SmallVector< BlockAction, 4 > | blockActions |
Ordered list of block operations (creations, splits, motions). More... | |
SetVector< Operation * > | ignoredOps |
A set of operations that should no longer be considered for legalization, but were not directly replace/erased/etc. More... | |
SmallVector< OperationTransactionState, 4 > | rootUpdates |
A transaction state for each of operations that were updated in-place. More... | |
SmallVector< unsigned, 4 > | operationsWithChangedResults |
A vector of indices into replacements of operations that were replaced with values with different result types than the original operation, e.g. More... | |
TypeConverter * | currentTypeConverter = nullptr |
The current type converter, or nullptr if no type converter is currently active. More... | |
function_ref< void(Diagnostic &)> | notifyCallback |
This allows the user to collect the match failure message. More... | |
SmallPtrSet< Operation *, 1 > | pendingRootUpdates |
A set of operations that have pending updates. More... | |
llvm::ScopedPrinter | logger {llvm::dbgs()} |
A logger used to emit diagnostics during the conversion process. More... | |
Definition at line 856 of file DialectConversion.cpp.
|
inlineexplicit |
Definition at line 857 of file DialectConversion.cpp.
void ConversionPatternRewriterImpl::applyRewrites | ( | ) |
Apply all requested operation rewrites.
This method is invoked when the conversion process succeeds.
Definition at line 1061 of file DialectConversion.cpp.
References mlir::Value::cast(), mlir::IRObjectWithUseList< OperandType >::dropAllUses(), mlir::Operation::getBlock(), mlir::detail::IROperandBase::getOwner(), mlir::Value::isa(), and mlir::Operation::isBeforeInBlock().
Block * ConversionPatternRewriterImpl::applySignatureConversion | ( | Region * | region, |
TypeConverter::SignatureConversion & | conversion, | ||
TypeConverter * | converter | ||
) |
Apply a signature conversion on the given region, using converter
for materializations if not null.
Definition at line 1347 of file DialectConversion.cpp.
References mlir::Region::empty(), and mlir::Region::front().
FailureOr< Block * > ConversionPatternRewriterImpl::convertBlockSignature | ( | Block * | block, |
TypeConverter * | converter, | ||
TypeConverter::SignatureConversion * | conversion = nullptr |
||
) |
Convert the signature of the given block.
Definition at line 1330 of file DialectConversion.cpp.
References mlir::failed(), and mlir::failure().
Referenced by mlir::ConversionPattern::matchAndRewrite().
LogicalResult ConversionPatternRewriterImpl::convertNonEntryRegionTypes | ( | Region * | region, |
TypeConverter & | converter, | ||
ArrayRef< TypeConverter::SignatureConversion > | blockConversions = {} |
||
) |
Convert the types of non-entry block arguments within the given region.
Definition at line 1370 of file DialectConversion.cpp.
References mlir::Region::empty(), mlir::failed(), mlir::failure(), mlir::Region::getBlocks(), and mlir::success().
FailureOr< Block * > ConversionPatternRewriterImpl::convertRegionTypes | ( | Region * | region, |
TypeConverter & | converter, | ||
TypeConverter::SignatureConversion * | entryConversion | ||
) |
Convert the types of block arguments within the given region.
Definition at line 1355 of file DialectConversion.cpp.
References mlir::Region::empty(), mlir::failed(), mlir::failure(), and mlir::Region::front().
void ConversionPatternRewriterImpl::discardRewrites | ( | ) |
Cleanup and destroy any generated rewrite operations.
This method is invoked when the conversion process fails.
Definition at line 1047 of file DialectConversion.cpp.
References detachNestedAndErase().
void ConversionPatternRewriterImpl::eraseDanglingBlocks | ( | ) |
Erase any blocks that were unlinked from their regions and stored in block actions.
Definition at line 1181 of file DialectConversion.cpp.
RewriterState ConversionPatternRewriterImpl::getCurrentState | ( | ) |
Return the current state of the rewriter.
Definition at line 1122 of file DialectConversion.cpp.
Referenced by mlir::ConversionPattern::matchAndRewrite().
bool ConversionPatternRewriterImpl::isOpIgnored | ( | Operation * | op | ) | const |
Returns true if the given operation is ignored, and does not need to be converted.
Definition at line 1309 of file DialectConversion.cpp.
References mlir::Operation::getParentOp().
Referenced by computeNecessaryMaterializations(), findLiveUserOfReplaced(), legalizeUnresolvedMaterialization(), and mlir::ConversionPattern::matchAndRewrite().
Recursively marks the nested operations under 'op' as ignored.
This removes them from being considered for legalization.
Definition at line 1314 of file DialectConversion.cpp.
References mlir::Operation::getNumRegions(), mlir::Operation::getRegions(), and mlir::Operation::walk().
Referenced by mlir::ConversionPattern::matchAndRewrite().
Notifies that a block is about to be erased.
Definition at line 1432 of file DialectConversion.cpp.
References mlir::Block::getParent(), and mlir::Block::push_back().
Notifies that block
is being merged with srcBlock
.
Definition at line 1447 of file DialectConversion.cpp.
Notifies that a block was created.
Definition at line 1438 of file DialectConversion.cpp.
LogicalResult ConversionPatternRewriterImpl::notifyMatchFailure | ( | Location | loc, |
function_ref< void(Diagnostic &)> | reasonCallback | ||
) |
Notifies that a pattern match failed for the given reason.
Definition at line 1479 of file DialectConversion.cpp.
References diag(), mlir::failure(), mlir::Remark, and mlir::Diagnostic::str().
void ConversionPatternRewriterImpl::notifyOpReplaced | ( | Operation * | op, |
ValueRange | newValues | ||
) |
PatternRewriter hook for replacing the results of an operation.
Definition at line 1401 of file DialectConversion.cpp.
References mlir::Operation::getNumResults(), mlir::Operation::getResults(), and mlir::Value::getType().
void ConversionPatternRewriterImpl::notifyRegionIsBeingInlinedBefore | ( | Region & | region, |
Region & | parent, | ||
Region::iterator | before | ||
) |
Notifies that the blocks of a region are about to be moved.
Definition at line 1452 of file DialectConversion.cpp.
References mlir::Region::back(), mlir::Region::empty(), and mlir::Block::push_back().
void ConversionPatternRewriterImpl::notifyRegionWasClonedBefore | ( | iterator_range< Region::iterator > & | blocks, |
Location | origRegionLoc | ||
) |
Notifies that the blocks of a region were cloned into another.
Definition at line 1465 of file DialectConversion.cpp.
References computeConversionSet(), and mlir::succeeded().
Notifies that a block was split.
Definition at line 1442 of file DialectConversion.cpp.
LogicalResult ConversionPatternRewriterImpl::remapValues | ( | StringRef | valueDiagTag, |
Optional< Location > | inputLoc, | ||
PatternRewriter & | rewriter, | ||
ValueRange | values, | ||
SmallVectorImpl< Value > & | remapped | ||
) |
Remap the given values to those with potentially different types.
Returns success if the values could be remapped, failure otherwise. valueDiagTag
is the tag used when describing a value within a diagnostic, e.g. "operand".
Definition at line 1255 of file DialectConversion.cpp.
References buildUnresolvedTargetMaterialization(), diag(), mlir::detail::enumerate(), mlir::failed(), mlir::Value::getLoc(), mlir::Value::getType(), and mlir::success().
void ConversionPatternRewriterImpl::resetState | ( | RewriterState | state | ) |
Reset the state of the rewriter to a previously saved point.
Definition at line 1129 of file DialectConversion.cpp.
References detachNestedAndErase().
Undo the block actions (motions, splits) one by one in reverse order until "numActionsToKeep" actions remains.
Definition at line 1187 of file DialectConversion.cpp.
References mlir::Block::begin(), mlir::Region::end(), mlir::Region::getBlocks(), and mlir::Block::getOperations().
ArgConverter mlir::detail::ConversionPatternRewriterImpl::argConverter |
Utility used to convert block arguments.
Definition at line 970 of file DialectConversion.cpp.
Referenced by mlir::ConversionPattern::matchAndRewrite().
SmallVector<BlockArgument, 4> mlir::detail::ConversionPatternRewriterImpl::argReplacements |
Ordered vector of any requested block argument replacements.
Definition at line 983 of file DialectConversion.cpp.
SmallVector<BlockAction, 4> mlir::detail::ConversionPatternRewriterImpl::blockActions |
Ordered list of block operations (creations, splits, motions).
Definition at line 986 of file DialectConversion.cpp.
Referenced by mlir::ConversionPattern::matchAndRewrite().
SmallVector<Operation *> mlir::detail::ConversionPatternRewriterImpl::createdOps |
Ordered vector of all of the newly created operations during conversion.
Definition at line 973 of file DialectConversion.cpp.
Referenced by mlir::ConversionPattern::matchAndRewrite().
TypeConverter* mlir::detail::ConversionPatternRewriterImpl::currentTypeConverter = nullptr |
The current type converter, or nullptr if no type converter is currently active.
Definition at line 1009 of file DialectConversion.cpp.
A set of operations that should no longer be considered for legalization, but were not directly replace/erased/etc.
by a pattern. These are generally child operations of other operations who were replaced/erased/etc. This is not meant to be an exhaustive list of all operations, but the minimal set that can be used to detect if a given operation should be ignored
. For example, we may add the operations that define non-empty regions to the set, but not any of the others. This simplifies the amount of memory needed as we can query if the parent operation was ignored.
Definition at line 997 of file DialectConversion.cpp.
Referenced by legalizeUnresolvedMaterialization().
llvm::ScopedPrinter mlir::detail::ConversionPatternRewriterImpl::logger {llvm::dbgs()} |
A logger used to emit diagnostics during the conversion process.
Definition at line 1021 of file DialectConversion.cpp.
Referenced by mlir::ConversionPattern::matchAndRewrite().
ConversionValueMapping mlir::detail::ConversionPatternRewriterImpl::mapping |
Definition at line 967 of file DialectConversion.cpp.
Referenced by computeNecessaryMaterializations(), findLiveUserOfReplaced(), legalizeUnresolvedMaterialization(), and replaceMaterialization().
function_ref<void(Diagnostic &)> mlir::detail::ConversionPatternRewriterImpl::notifyCallback |
This allows the user to collect the match failure message.
Definition at line 1012 of file DialectConversion.cpp.
SmallVector<unsigned, 4> mlir::detail::ConversionPatternRewriterImpl::operationsWithChangedResults |
A vector of indices into replacements
of operations that were replaced with values with different result types than the original operation, e.g.
1->N conversion of some kind.
Definition at line 1005 of file DialectConversion.cpp.
SmallPtrSet<Operation *, 1> mlir::detail::ConversionPatternRewriterImpl::pendingRootUpdates |
A set of operations that have pending updates.
This tracking isn't strictly necessary, and is thus only active during debug builds for extra verification.
Definition at line 1018 of file DialectConversion.cpp.
llvm::MapVector<Operation *, OpReplacement> mlir::detail::ConversionPatternRewriterImpl::replacements |
Ordered map of requested operation replacements.
Definition at line 980 of file DialectConversion.cpp.
SmallVector<OperationTransactionState, 4> mlir::detail::ConversionPatternRewriterImpl::rootUpdates |
A transaction state for each of operations that were updated in-place.
Definition at line 1000 of file DialectConversion.cpp.
Referenced by mlir::ConversionPattern::matchAndRewrite().
SmallVector<UnresolvedMaterialization> mlir::detail::ConversionPatternRewriterImpl::unresolvedMaterializations |
Ordered vector of all unresolved type conversion materializations during conversion.
Definition at line 977 of file DialectConversion.cpp.
Referenced by computeNecessaryMaterializations(), and legalizeUnresolvedMaterialization().