CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
circt::OpReduction< OpTy > Struct Template Reference

A reduction pattern for a specific operation. More...

#include <Reduction.h>

Inheritance diagram for circt::OpReduction< OpTy >:
Inheritance graph
[legend]
Collaboration diagram for circt::OpReduction< OpTy >:
Collaboration graph
[legend]

Public Member Functions

void matches (Operation *op, llvm::function_ref< void(uint64_t, uint64_t)> addMatch) override
 Collect all ways how this reduction can apply to a specific operation.
 
LogicalResult rewriteMatches (Operation *op, ArrayRef< uint64_t > matches) override
 Apply a set of matches of this reduction to a specific operation.
 
virtual uint64_t match (OpTy op)
 
virtual void matches (OpTy op, llvm::function_ref< void(uint64_t, uint64_t)> addMatch)
 
virtual LogicalResult rewrite (OpTy op)
 
virtual LogicalResult rewriteMatches (OpTy op, ArrayRef< uint64_t > matches)
 
- Public Member Functions inherited from circt::Reduction
virtual ~Reduction ()
 
virtual void beforeReduction (mlir::ModuleOp)
 Called before the reduction is applied to a new subset of operations.
 
virtual void afterReduction (mlir::ModuleOp)
 Called after the reduction has been applied to a subset of operations.
 
virtual std::string getName () const =0
 Return a human-readable name for this reduction pattern.
 
virtual bool acceptSizeIncrease () const
 Return true if the tool should accept the transformation this reduction performs on the module even if the overall size of the output increases.
 
virtual bool isOneShot () const
 Return true if the tool should not try to reapply this reduction after it has been successful.
 
void notifyOpErased (Operation *op)
 

Private Member Functions

virtual uint64_t match (Operation *op)
 Hide the base class match/rewrite functions to prevent compiler warnings about the OpTy-specific ones hiding the base class functions.
 
virtual LogicalResult rewrite (Operation *op)
 Apply the reduction to a specific operation.
 

Additional Inherited Members

- Public Attributes inherited from circt::Reduction
std::function< void(Operation *)> notifyOpErasedCallback = nullptr
 An optional callback for reductions to communicate removal of operations.
 

Detailed Description

template<typename OpTy>
struct circt::OpReduction< OpTy >

A reduction pattern for a specific operation.

Only matches on operations of type OpTy, and calls corresponding match and rewrite functions with the operation cast to this type, for convenience.

Definition at line 112 of file Reduction.h.

Member Function Documentation

◆ match() [1/2]

template<typename OpTy >
virtual uint64_t circt::Reduction::match ( Operation *  op)
inlineprivatevirtual

Hide the base class match/rewrite functions to prevent compiler warnings about the OpTy-specific ones hiding the base class functions.

Reimplemented from circt::Reduction.

Definition at line 41 of file Reduction.h.

◆ match() [2/2]

template<typename OpTy >
virtual uint64_t circt::OpReduction< OpTy >::match ( OpTy  op)
inlinevirtual

Definition at line 123 of file Reduction.h.

Referenced by circt::OpReduction< OpTy >::matches().

◆ matches() [1/2]

template<typename OpTy >
void circt::OpReduction< OpTy >::matches ( Operation *  op,
llvm::function_ref< void(uint64_t, uint64_t)>  addMatch 
)
inlineoverridevirtual

Collect all ways how this reduction can apply to a specific operation.

If a reduction can apply to an operation in different ways, for example deleting different operands, it should call addMatch multiple times with the expected benefit of the match, as well as an integer identifying one of the different ways it can match.

Calls match(op) by default.

Reimplemented from circt::Reduction.

Definition at line 113 of file Reduction.h.

References circt::OpReduction< OpTy >::matches().

Referenced by circt::OpReduction< OpTy >::matches(), circt::OpReduction< OpTy >::rewriteMatches(), and circt::OpReduction< OpTy >::rewriteMatches().

◆ matches() [2/2]

template<typename OpTy >
virtual void circt::OpReduction< OpTy >::matches ( OpTy  op,
llvm::function_ref< void(uint64_t, uint64_t)>  addMatch 
)
inlinevirtual

Definition at line 124 of file Reduction.h.

References circt::OpReduction< OpTy >::match().

◆ rewrite() [1/2]

template<typename OpTy >
virtual LogicalResult circt::Reduction::rewrite ( Operation *  op)
inlineprivatevirtual

Apply the reduction to a specific operation.

If the returned result indicates that the application failed, the resulting module is treated the same as if the tester marked it as uninteresting.

Reimplemented from circt::Reduction.

Definition at line 58 of file Reduction.h.

◆ rewrite() [2/2]

template<typename OpTy >
virtual LogicalResult circt::OpReduction< OpTy >::rewrite ( OpTy  op)
inlinevirtual

Reimplemented in StateElimination.

Definition at line 128 of file Reduction.h.

Referenced by circt::OpReduction< OpTy >::rewriteMatches().

◆ rewriteMatches() [1/2]

template<typename OpTy >
LogicalResult circt::OpReduction< OpTy >::rewriteMatches ( Operation *  op,
ArrayRef< uint64_t >  matches 
)
inlineoverridevirtual

Apply a set of matches of this reduction to a specific operation.

If the reduction registered multiple matches for an operation, a subset of the integer identifiers of those matches will be passed to this function again. If the returned result indicates that the application failed, the resulting module is treated the same as if the tester marked it as uninteresting.

Reimplemented from circt::Reduction.

Definition at line 118 of file Reduction.h.

References circt::OpReduction< OpTy >::matches(), and circt::OpReduction< OpTy >::rewriteMatches().

Referenced by circt::OpReduction< OpTy >::rewriteMatches().

◆ rewriteMatches() [2/2]

template<typename OpTy >
virtual LogicalResult circt::OpReduction< OpTy >::rewriteMatches ( OpTy  op,
ArrayRef< uint64_t >  matches 
)
inlinevirtual

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