CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
circt::synth::CutRewritePattern Struct Referenceabstract

Base class for cut rewriting patterns used in combinational logic optimization. More...

#include <CutRewriter.h>

Inheritance diagram for circt::synth::CutRewritePattern:
Inheritance graph
[legend]
Collaboration diagram for circt::synth::CutRewritePattern:
Collaboration graph
[legend]

Public Member Functions

 CutRewritePattern (mlir::MLIRContext *context)
 
virtual ~CutRewritePattern ()=default
 Virtual destructor for base class.
 
virtual std::optional< MatchResultmatch (CutEnumerator &enumerator, const Cut &cut) const =0
 Check if a cut matches this pattern and compute area/delay metrics.
 
virtual bool useTruthTableMatcher (SmallVectorImpl< NPNClass > &matchingNPNClasses) const
 Specify truth tables that this pattern can match.
 
virtual FailureOr< Operation * > rewrite (mlir::OpBuilder &builder, CutEnumerator &enumerator, const Cut &cut) const =0
 Return a new operation that replaces the matched cut.
 
virtual unsigned getNumOutputs () const =0
 Get the number of outputs this pattern produces.
 
virtual StringRef getPatternName () const
 Get the name of this pattern. Used for debugging.
 
virtual LocationAttr getLoc () const
 Get location for this pattern(optional).
 
mlir::MLIRContext * getContext () const
 

Private Attributes

mlir::MLIRContext * context
 

Detailed Description

Base class for cut rewriting patterns used in combinational logic optimization.

A CutRewritePattern represents a library component or optimization pattern that can replace cuts in the combinational logic network. Each pattern defines:

Patterns can use truth table matching for efficient recognition or implement custom matching logic for more complex cases.

Definition at line 389 of file CutRewriter.h.

Constructor & Destructor Documentation

◆ CutRewritePattern()

circt::synth::CutRewritePattern::CutRewritePattern ( mlir::MLIRContext *  context)
inline

Definition at line 390 of file CutRewriter.h.

◆ ~CutRewritePattern()

virtual circt::synth::CutRewritePattern::~CutRewritePattern ( )
virtualdefault

Virtual destructor for base class.

Member Function Documentation

◆ getContext()

mlir::MLIRContext * circt::synth::CutRewritePattern::getContext ( ) const
inline

Definition at line 437 of file CutRewriter.h.

References context.

◆ getLoc()

virtual LocationAttr circt::synth::CutRewritePattern::getLoc ( ) const
inlinevirtual

Get location for this pattern(optional).

Reimplemented in TechLibraryPattern.

Definition at line 435 of file CutRewriter.h.

References context.

◆ getNumOutputs()

virtual unsigned circt::synth::CutRewritePattern::getNumOutputs ( ) const
pure virtual

Get the number of outputs this pattern produces.

Implemented in GenericLUT, and TechLibraryPattern.

◆ getPatternName()

virtual StringRef circt::synth::CutRewritePattern::getPatternName ( ) const
inlinevirtual

Get the name of this pattern. Used for debugging.

Reimplemented in GenericLUT, and TechLibraryPattern.

Definition at line 432 of file CutRewriter.h.

◆ match()

virtual std::optional< MatchResult > circt::synth::CutRewritePattern::match ( CutEnumerator enumerator,
const Cut cut 
) const
pure virtual

Check if a cut matches this pattern and compute area/delay metrics.

This method is called to determine if a cut can be replaced by this pattern. If the cut matches, it should return a MatchResult containing the area and per-input delays for this specific cut.

If useTruthTableMatcher() returns true, this method is only called for cuts with matching truth tables.

Implemented in GenericLUT, and TechLibraryPattern.

◆ rewrite()

virtual FailureOr< Operation * > circt::synth::CutRewritePattern::rewrite ( mlir::OpBuilder &  builder,
CutEnumerator enumerator,
const Cut cut 
) const
pure virtual

Return a new operation that replaces the matched cut.

Unlike MLIR's RewritePattern framework which allows arbitrary in-place modifications, this method creates a new operation to replace the matched cut rather than modifying existing operations. This constraint exists because the cut enumerator maintains references to operations throughout the circuit, making it safe to only replace the root operation of each cut while preserving all other operations unchanged.

Implemented in TechLibraryPattern, and GenericLUT.

◆ useTruthTableMatcher()

bool CutRewritePattern::useTruthTableMatcher ( SmallVectorImpl< NPNClass > &  matchingNPNClasses) const
virtual

Specify truth tables that this pattern can match.

If this method returns true, the pattern matcher will use truth table comparison for efficient pre-filtering. Only cuts with matching truth tables will be passed to the match() method. If it returns false, the pattern will be checked against all cuts regardless of their truth tables. This is useful for patterns that match regardless of their truth tables, such as LUT-based patterns.

Reimplemented in TechLibraryPattern.

Definition at line 616 of file CutRewriter.cpp.

Member Data Documentation

◆ context

mlir::MLIRContext* circt::synth::CutRewritePattern::context
private

Definition at line 440 of file CutRewriter.h.

Referenced by getContext(), and getLoc().


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