MLIR 22.0.0git
mlir::RewriterBase::ForwardingListener Struct Reference

A listener that forwards all notifications to another listener. More...

#include "mlir/IR/PatternMatch.h"

Inheritance diagram for mlir::RewriterBase::ForwardingListener:

Public Member Functions

 ForwardingListener (OpBuilder::Listener *listener)
void notifyOperationInserted (Operation *op, InsertPoint previous) override
 Notify the listener that the specified operation was inserted.
void notifyBlockInserted (Block *block, Region *previous, Region::iterator previousIt) override
 Notify the listener that the specified block was inserted.
void notifyBlockErased (Block *block) override
 Notify the listener that the specified block is about to be erased.
void notifyOperationModified (Operation *op) override
 Notify the listener that the specified operation was modified in-place.
void notifyOperationReplaced (Operation *op, Operation *newOp) override
 Notify the listener that all uses of the specified operation's results are about to be replaced with the results of another operation.
void notifyOperationReplaced (Operation *op, ValueRange replacement) override
 Notify the listener that all uses of the specified operation's results are about to be replaced with the a range of values, potentially produced by other operations.
void notifyOperationErased (Operation *op) override
 Notify the listener that the specified operation is about to be erased.
void notifyPatternBegin (const Pattern &pattern, Operation *op) override
 Notify the listener that the specified pattern is about to be applied at the specified root operation.
void notifyPatternEnd (const Pattern &pattern, LogicalResult status) override
 Notify the listener that a pattern application finished with the specified status.
void notifyMatchFailure (Location loc, function_ref< void(Diagnostic &)> reasonCallback) override
 Notify the listener that the pattern failed to match, and provide a callback to populate a diagnostic with the reason why the failure occurred.
Public Member Functions inherited from mlir::RewriterBase::Listener
 Listener ()
Public Member Functions inherited from mlir::OpBuilder::Listener
 Listener ()
virtual ~Listener ()=default
Public Member Functions inherited from mlir::OpBuilder::ListenerBase
Kind getKind () const

Additional Inherited Members

Public Types inherited from mlir::OpBuilder::ListenerBase
enum class  Kind { OpBuilderListener = 0 , RewriterBaseListener = 1 }
 The kind of listener. More...
Static Public Member Functions inherited from mlir::RewriterBase::Listener
static bool classof (const OpBuilder::Listener *base)
Protected Member Functions inherited from mlir::OpBuilder::Listener
 Listener (Kind kind)
Protected Member Functions inherited from mlir::OpBuilder::ListenerBase
 ListenerBase (Kind kind)

Detailed Description

A listener that forwards all notifications to another listener.

This struct can be used as a base to create listener chains, so that multiple listeners can be notified of IR changes.

Definition at line 431 of file PatternMatch.h.

Constructor & Destructor Documentation

◆ ForwardingListener()

mlir::RewriterBase::ForwardingListener::ForwardingListener ( OpBuilder::Listener * listener)
inline

Member Function Documentation

◆ notifyBlockErased()

void mlir::RewriterBase::ForwardingListener::notifyBlockErased ( Block * block)
inlineoverridevirtual

Notify the listener that the specified block is about to be erased.

At this point, the block has zero uses.

Reimplemented from mlir::RewriterBase::Listener.

Definition at line 446 of file PatternMatch.h.

◆ notifyBlockInserted()

void mlir::RewriterBase::ForwardingListener::notifyBlockInserted ( Block * block,
Region * previous,
Region::iterator previousIt )
inlineoverridevirtual

Notify the listener that the specified block was inserted.

  • If the block was moved, then previous and previousIt are the previous location of the block.
  • If the block was unlinked before it was inserted, then previous is "nullptr".

Note: Creating an (unlinked) block does not trigger this notification.

Reimplemented from mlir::OpBuilder::Listener.

Definition at line 441 of file PatternMatch.h.

◆ notifyMatchFailure()

void mlir::RewriterBase::ForwardingListener::notifyMatchFailure ( Location loc,
function_ref< void(Diagnostic &)> reasonCallback )
inlineoverridevirtual

Notify the listener that the pattern failed to match, and provide a callback to populate a diagnostic with the reason why the failure occurred.

This method allows for derived listeners to optionally hook into the reason why a rewrite failed, and display it to users.

Reimplemented from mlir::RewriterBase::Listener.

Definition at line 476 of file PatternMatch.h.

◆ notifyOperationErased()

void mlir::RewriterBase::ForwardingListener::notifyOperationErased ( Operation * op)
inlineoverridevirtual

Notify the listener that the specified operation is about to be erased.

At this point, the operation has zero uses.

Note: This notification is not triggered when unlinking an operation.

Reimplemented from mlir::RewriterBase::Listener.

Reimplemented in mlir::RewriterBase::PatternLoggingListener.

Definition at line 463 of file PatternMatch.h.

Referenced by mlir::RewriterBase::PatternLoggingListener::notifyOperationErased().

◆ notifyOperationInserted()

void mlir::RewriterBase::ForwardingListener::notifyOperationInserted ( Operation * op,
InsertPoint previous )
inlineoverridevirtual

Notify the listener that the specified operation was inserted.

  • If the operation was moved, then previous is the previous location of the op.
  • If the operation was unlinked before it was inserted, then previous is empty.

Note: Creating an (unlinked) op does not trigger this notification.

Reimplemented from mlir::OpBuilder::Listener.

Reimplemented in mlir::RewriterBase::PatternLoggingListener.

Definition at line 437 of file PatternMatch.h.

Referenced by mlir::RewriterBase::PatternLoggingListener::notifyOperationInserted().

◆ notifyOperationModified()

void mlir::RewriterBase::ForwardingListener::notifyOperationModified ( Operation * op)
inlineoverridevirtual

Notify the listener that the specified operation was modified in-place.

Reimplemented from mlir::RewriterBase::Listener.

Reimplemented in mlir::RewriterBase::PatternLoggingListener.

Definition at line 450 of file PatternMatch.h.

Referenced by mlir::RewriterBase::PatternLoggingListener::notifyOperationModified().

◆ notifyOperationReplaced() [1/2]

void mlir::RewriterBase::ForwardingListener::notifyOperationReplaced ( Operation * op,
Operation * replacement )
inlineoverridevirtual

Notify the listener that all uses of the specified operation's results are about to be replaced with the results of another operation.

This is called before the uses of the old operation have been changed.

By default, this function calls the "operation replaced with values" notification.

Reimplemented from mlir::RewriterBase::Listener.

Reimplemented in mlir::RewriterBase::PatternLoggingListener.

Definition at line 454 of file PatternMatch.h.

Referenced by mlir::RewriterBase::PatternLoggingListener::notifyOperationReplaced(), and mlir::RewriterBase::PatternLoggingListener::notifyOperationReplaced().

◆ notifyOperationReplaced() [2/2]

void mlir::RewriterBase::ForwardingListener::notifyOperationReplaced ( Operation * op,
ValueRange replacement )
inlineoverridevirtual

Notify the listener that all uses of the specified operation's results are about to be replaced with the a range of values, potentially produced by other operations.

This is called before the uses of the operation have been changed.

Reimplemented from mlir::RewriterBase::Listener.

Reimplemented in mlir::RewriterBase::PatternLoggingListener.

Definition at line 458 of file PatternMatch.h.

References replacement().

◆ notifyPatternBegin()

void mlir::RewriterBase::ForwardingListener::notifyPatternBegin ( const Pattern & pattern,
Operation * op )
inlineoverridevirtual

Notify the listener that the specified pattern is about to be applied at the specified root operation.

Reimplemented from mlir::RewriterBase::Listener.

Reimplemented in mlir::RewriterBase::PatternLoggingListener.

Definition at line 467 of file PatternMatch.h.

Referenced by mlir::RewriterBase::PatternLoggingListener::notifyPatternBegin().

◆ notifyPatternEnd()

void mlir::RewriterBase::ForwardingListener::notifyPatternEnd ( const Pattern & pattern,
LogicalResult status )
inlineoverridevirtual

Notify the listener that a pattern application finished with the specified status.

"success" indicates that the pattern was applied successfully. "failure" indicates that the pattern could not be applied. The pattern may have communicated the reason for the failure with notifyMatchFailure.

Reimplemented from mlir::RewriterBase::Listener.

Definition at line 471 of file PatternMatch.h.


The documentation for this struct was generated from the following file: