Skip to content

[MatchRewrite] Querying pre-replacement types in rewrite functions #84

@vaivaswatha

Description

@vaivaswatha

The rewriter must keep track of type of replaced values (new value -> replaced value type). This should be query-able from MatchRewrite::rewrite.

During dialect conversions, when rewriting an operation, if the definition of an operand has been replaced (with a possibly new type), converting the operation without the earlier (pre-conversion) type of that operand may not be possible. So that must be kept track of (transitively) and the mapping provided upon request.

MLIR takes the opposite route. The operation provided as the main argument to rewrite will have all its operands unconverted, and the converted types can be queried from the OpAdaptor argument. i.e., old value -> new value type mapping is maintained. (see ConversionPatternRewriterImpl::replaceOp)

Note: A clone, of the top level operation (from where rewrite is performed) is performed and the clone undergoes rewrites, finally committing the clone on success. (reference: mlir::applyAnalysisConversion)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions