MLIR  20.0.0git
Public Member Functions | List of all members
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. More...
 
void notifyBlockInserted (Block *block, Region *previous, Region::iterator previousIt) override
 Notify the listener that the specified block was inserted. More...
 
void notifyBlockErased (Block *block) override
 Notify the listener that the specified block is about to be erased. More...
 
void notifyOperationModified (Operation *op) override
 Notify the listener that the specified operation was modified in-place. More...
 
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. More...
 
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. More...
 
void notifyOperationErased (Operation *op) override
 Notify the listener that the specified operation is about to be erased. More...
 
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. More...
 
void notifyPatternEnd (const Pattern &pattern, LogicalResult status) override
 Notify the listener that a pattern application finished with the specified status. More...
 
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. More...
 
- 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 463 of file PatternMatch.h.

Constructor & Destructor Documentation

◆ ForwardingListener()

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

Definition at line 464 of file PatternMatch.h.

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 478 of file PatternMatch.h.

References mlir::RewriterBase::Listener::notifyBlockErased().

◆ 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 473 of file PatternMatch.h.

References mlir::OpBuilder::Listener::notifyBlockInserted().

◆ 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 508 of file PatternMatch.h.

References mlir::RewriterBase::Listener::notifyMatchFailure().

◆ 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.

Definition at line 495 of file PatternMatch.h.

References mlir::RewriterBase::Listener::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.

Definition at line 469 of file PatternMatch.h.

References mlir::OpBuilder::Listener::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.

Definition at line 482 of file PatternMatch.h.

References mlir::RewriterBase::Listener::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.

Definition at line 486 of file PatternMatch.h.

References mlir::RewriterBase::Listener::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.

Definition at line 490 of file PatternMatch.h.

References mlir::RewriterBase::Listener::notifyOperationReplaced().

◆ 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.

Definition at line 499 of file PatternMatch.h.

References mlir::RewriterBase::Listener::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 503 of file PatternMatch.h.

References mlir::RewriterBase::Listener::notifyPatternEnd().


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