[all-commits] [llvm/llvm-project] 37fe55: [mlir][IR][NFC] Improve listener layering in diale...

Matthias Springer via All-commits all-commits at lists.llvm.org
Fri Feb 9 01:20:17 PST 2024


  Branch: refs/heads/users/matthias-springer/conversion_pattern_rewriter_listener
  Home:   https://github.com/llvm/llvm-project
  Commit: 37fe55824643e63aa79743af06375f809e43caed
      https://github.com/llvm/llvm-project/commit/37fe55824643e63aa79743af06375f809e43caed
  Author: Matthias Springer <springerm at google.com>
  Date:   2024-02-09 (Fri, 09 Feb 2024)

  Changed paths:
    M mlir/include/mlir/Transforms/DialectConversion.h
    M mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
    M mlir/lib/Transforms/Utils/DialectConversion.cpp

  Log Message:
  -----------
  [mlir][IR][NFC] Improve listener layering in dialect conversion

Context: Conversion patterns provide a `ConversionPatternRewriter` to modify the IR. `ConversionPatternRewriter` provides the public API. Most function calls are forwarded/handled by `ConversionPatternRewriterImpl`. The dialect conversion uses the listener infrastructure to get notified about op/block insertions.

In the current design, `ConversionPatternRewriter` inherits from both `PatternRewriter` and `Listener`. The conversion rewriter registers itself as a listener. This is problematic because listener functions such as `notifyOperationInserted` are now part of the public API and can be called from conversion patterns; that would bring the dialect conversion into an inconsistent state.

With this commit, `ConversionPatternRewriter` no longer inherits from `Listener`. Instead `ConversionPatternRewriterImpl` inherits from `Listener`. This removes the problematic public API and also simplifies the code a bit: block/op insertion notifications were previously forwarded to the `ConversionPatternRewriterImpl`. This is no longer needed.




More information about the All-commits mailing list