MLIR
22.0.0git
|
Dialect conversion configuration. More...
#include "mlir/Transforms/DialectConversion.h"
Public Attributes | |
function_ref< void(Diagnostic &)> | notifyCallback = nullptr |
An optional callback used to notify about match failure diagnostics during the conversion. More... | |
DenseSet< Operation * > * | unlegalizedOps = nullptr |
Partial conversion only. More... | |
DenseSet< Operation * > * | legalizableOps = nullptr |
Analysis conversion only. More... | |
RewriterBase::Listener * | listener = nullptr |
An optional listener that is notified about all IR modifications in case dialect conversion succeeds. More... | |
bool | buildMaterializations = true |
If set to "true", the dialect conversion attempts to build source/target materializations through the type converter API in lieu of "builtin.unrealized_conversion_cast ops". More... | |
bool | allowPatternRollback = true |
If set to "true", pattern rollback is allowed. More... | |
DialectConversionFoldingMode | foldingMode |
The folding mode to use during conversion. More... | |
bool | attachDebugMaterializationKind = false |
If set to "true", the materialization kind ("source" or "target") will be attached to "builtin.unrealized_conversion_cast" ops. More... | |
Dialect conversion configuration.
Definition at line 1297 of file DialectConversion.h.
bool mlir::ConversionConfig::allowPatternRollback = true |
If set to "true", pattern rollback is allowed.
The conversion driver rolls back IR modifications in the following situations.
Experimental: If set to "false", the conversion driver will produce an LLVM fatal error instead of rolling back IR modifications. Moreover, in case of a failed conversion, the original IR is not restored. The resulting IR may be a mix of original and rewritten IR. (Same as a failed greedy pattern rewrite.) Use the cmake build option -DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON
(ideally together with ASAN) to detect invalid pattern API usage.
When pattern rollback is disabled, the conversion driver has to maintain less internal state. This is more efficient, but not supported by all lowering patterns. For details, see https://discourse.llvm.org/t/rfc-a-new-one-shot-dialect-conversion-driver/79083.
Definition at line 1378 of file DialectConversion.h.
Referenced by mlir::detail::ConversionPatternRewriterImpl::applySignatureConversion(), mlir::detail::ConversionPatternRewriterImpl::buildUnresolvedMaterialization(), mlir::OperationConverter::convertOperations(), mlir::detail::ConversionPatternRewriterImpl::eraseBlock(), mlir::detail::ConversionPatternRewriterImpl::findOrBuildReplacementValue(), mlir::detail::ConversionPatternRewriterImpl::lookupOrDefault(), mlir::detail::ConversionPatternRewriterImpl::notifyBlockInserted(), mlir::detail::ConversionPatternRewriterImpl::notifyOperationInserted(), mlir::detail::ConversionPatternRewriterImpl::replaceOp(), and mlir::detail::ConversionPatternRewriterImpl::replaceUsesOfBlockArgument().
bool mlir::ConversionConfig::attachDebugMaterializationKind = false |
If set to "true", the materialization kind ("source" or "target") will be attached to "builtin.unrealized_conversion_cast" ops.
This flag is useful for debugging, to find out what kind of materialization rule may be missing.
Definition at line 1388 of file DialectConversion.h.
Referenced by mlir::detail::ConversionPatternRewriterImpl::buildUnresolvedMaterialization().
bool mlir::ConversionConfig::buildMaterializations = true |
If set to "true", the dialect conversion attempts to build source/target materializations through the type converter API in lieu of "builtin.unrealized_conversion_cast ops".
The conversion process fails if at least one materialization could not be built.
If set to "false", the dialect conversion does not build any custom materializations and instead inserts "builtin.unrealized_conversion_cast" ops to ensure that the resulting IR is valid.
Definition at line 1357 of file DialectConversion.h.
DialectConversionFoldingMode mlir::ConversionConfig::foldingMode |
The folding mode to use during conversion.
Definition at line 1381 of file DialectConversion.h.
Analysis conversion only.
All operations that are found to be legalizable are placed in this set. Note that no actual rewrites are applied to the IR during an analysis conversion and only pre-existing operations are added to the set.
Definition at line 1313 of file DialectConversion.h.
RewriterBase::Listener* mlir::ConversionConfig::listener = nullptr |
An optional listener that is notified about all IR modifications in case dialect conversion succeeds.
If the dialect conversion fails and no IR modifications are visible (i.e., they were all rolled back), or if the dialect conversion is an "analysis conversion", no notifications are sent (apart from notifyPatternBegin
/notifyPatternEnd`).
Note: Notifications are sent in a delayed fashion, when the dialect conversion is guaranteed to succeed. At that point, some IR modifications may already have been materialized. Consequently, operations/blocks that are passed to listener callbacks should not be accessed. (Ops/blocks are guaranteed to be valid pointers and accessing op names is allowed. But there are no guarantees about the state of ops/blocks at the time that a callback is triggered.)
Example: Consider a dialect conversion a new op ("test.foo") is created and inserted, and later moved to another block. (Moving ops also triggers "notifyOperationInserted".)
(1) notifyOperationInserted: "test.foo" (into block "b1") (2) notifyOperationInserted: "test.foo" (moved to another block "b2")
When querying "op->getBlock()" during the first "notifyOperationInserted", "b2" would be returned because "moving an op" is a kind of rewrite that is immediately performed by the dialect conversion (and rolled back upon failure).
Definition at line 1347 of file DialectConversion.h.
Referenced by mlir::detail::ConversionPatternRewriterImpl::applyRewrites(), mlir::detail::ConversionPatternRewriterImpl::applySignatureConversion(), mlir::detail::ConversionPatternRewriterImpl::notifyBlockInserted(), and mlir::detail::ConversionPatternRewriterImpl::notifyOperationInserted().
function_ref<void(Diagnostic &)> mlir::ConversionConfig::notifyCallback = nullptr |
An optional callback used to notify about match failure diagnostics during the conversion.
Diagnostics reported to this callback may only be available in debug mode.
Definition at line 1301 of file DialectConversion.h.
Referenced by mlir::detail::ConversionPatternRewriterImpl::notifyMatchFailure().
Partial conversion only.
All operations that are found not to be legalizable are placed in this set. (Note that if there is an op explicitly marked as illegal, the conversion terminates and the set will not necessarily be complete.)
Definition at line 1307 of file DialectConversion.h.
Referenced by mlir::detail::ConversionPatternRewriterImpl::eraseBlock(), and mlir::detail::ConversionPatternRewriterImpl::replaceOp().