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 bool match (const Cut &cut) const =0
 Check if a cut matches this pattern.
 
virtual bool useTruthTableMatcher (SmallVectorImpl< NPNClass > &matchingNPNClasses) const
 Specify truth tables that this pattern can match.
 
virtual FailureOr< Operation * > rewrite (mlir::OpBuilder &builder, Cut &cut) const =0
 Return a new operation that replaces the matched cut.
 
virtual double getArea () const =0
 Get the area cost of this pattern.
 
virtual DelayType getDelay (unsigned inputIndex, unsigned outputIndex) const =0
 Get the delay between specific input and output.
 
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 332 of file CutRewriter.h.

Constructor & Destructor Documentation

◆ CutRewritePattern()

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

Definition at line 333 of file CutRewriter.h.

◆ ~CutRewritePattern()

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

Virtual destructor for base class.

Member Function Documentation

◆ getArea()

virtual double circt::synth::CutRewritePattern::getArea ( ) const
pure virtual

Get the area cost of this pattern.

Implemented in GenericLUT, and TechLibraryPattern.

Referenced by circt::synth::MatchedPattern::getArea(), and circt::synth::CutRewriter::patternMatchCut().

◆ getContext()

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

Definition at line 384 of file CutRewriter.h.

References context.

◆ getDelay()

virtual DelayType circt::synth::CutRewritePattern::getDelay ( unsigned  inputIndex,
unsigned  outputIndex 
) const
pure virtual

Get the delay between specific input and output.

NOTE: The input index is already permuted according to the pattern's input permutation, so it's not necessary to account for it here.

Implemented in GenericLUT, and TechLibraryPattern.

Referenced by circt::synth::MatchedPattern::getDelay().

◆ getLoc()

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

Get location for this pattern(optional).

Reimplemented in TechLibraryPattern.

Definition at line 382 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 379 of file CutRewriter.h.

◆ match()

virtual bool circt::synth::CutRewritePattern::match ( const Cut cut) const
pure virtual

Check if a cut matches this pattern.

This method is called to determine if a cut can be replaced by this pattern. 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,
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 619 of file CutRewriter.cpp.

Member Data Documentation

◆ context

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

Definition at line 387 of file CutRewriter.h.

Referenced by getContext(), and getLoc().


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