CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
circt::synth::CutEnumerator Class Reference

Cut enumeration engine for combinational logic networks. More...

#include <CutRewriter.h>

Collaboration diagram for circt::synth::CutEnumerator:
Collaboration graph
[legend]

Public Member Functions

 CutEnumerator (const CutRewriterOptions &options)
 Constructor for cut enumerator.
 
LogicalResult enumerateCuts (Operation *topOp, llvm::function_ref< std::optional< MatchedPattern >(const Cut &)> matchCut=[](const Cut &) { return std::nullopt;})
 Enumerate cuts for all nodes in the given module.
 
CutSetcreateNewCutSet (Value value)
 Create a new cut set for a value.
 
const CutSetgetCutSet (Value value)
 Get the cut set for a specific value.
 
llvm::MapVector< Value, std::unique_ptr< CutSet > > takeVector ()
 Move ownership of all cut sets to caller.
 
void clear ()
 Clear all cut sets and reset the enumerator.
 
void dump () const
 

Private Member Functions

LogicalResult visit (Operation *op)
 Visit a single operation and generate cuts for it.
 
LogicalResult visitLogicOp (Operation *logicOp)
 Visit a combinational logic operation and generate cuts.
 

Private Attributes

llvm::MapVector< Value, std::unique_ptr< CutSet > > cutSets
 Maps values to their associated cut sets.
 
const CutRewriterOptionsoptions
 Configuration options for cut enumeration.
 
llvm::function_ref< std::optional< MatchedPattern >(const Cut &)> matchCut
 Function to match cuts against available patterns.
 

Detailed Description

Cut enumeration engine for combinational logic networks.

The CutEnumerator is responsible for generating cuts for each node in a combinational logic network. It uses a priority cuts algorithm to maintain a bounded set of promising cuts while avoiding exponential explosion.

The enumeration process works by:

  1. Visiting nodes in topological order
  2. For each node, combining cuts from its inputs
  3. Matching generated cuts against available patterns
  4. Maintaining only the most promising cuts per node

Definition at line 267 of file CutRewriter.h.

Constructor & Destructor Documentation

◆ CutEnumerator()

CutEnumerator::CutEnumerator ( const CutRewriterOptions options)
explicit

Constructor for cut enumerator.

Definition at line 639 of file CutRewriter.cpp.

Member Function Documentation

◆ clear()

void CutEnumerator::clear ( )

Clear all cut sets and reset the enumerator.

Definition at line 653 of file CutRewriter.cpp.

References cutSets.

Referenced by circt::synth::CutRewriter::runBottomUpRewrite().

◆ createNewCutSet()

CutSet * CutEnumerator::createNewCutSet ( Value  value)

Create a new cut set for a value.

The value must not already have a cut set.

Definition at line 642 of file CutRewriter.cpp.

References assert(), and cutSets.

Referenced by visitLogicOp().

◆ dump()

void CutEnumerator::dump ( ) const

Definition at line 831 of file CutRewriter.cpp.

References cutSets, getTestVariableName(), and pattern.

Referenced by circt::synth::CutRewriter::run().

◆ enumerateCuts()

LogicalResult CutEnumerator::enumerateCuts ( Operation *  topOp,
llvm::function_ref< std::optional< MatchedPattern >(const Cut &)>  matchCut = [](const Cut &) { return std::nullopt; } 
)

Enumerate cuts for all nodes in the given module.

This is the main entry point that orchestrates the cut enumeration process. It visits all operations in the module and generates cuts for combinational logic operations.

Definition at line 745 of file CutRewriter.cpp.

References matchCut, circt::synth::topologicallySortLogicNetwork(), and visit().

Referenced by circt::synth::CutRewriter::enumerateCuts().

◆ getCutSet()

const CutSet * CutEnumerator::getCutSet ( Value  value)

Get the cut set for a specific value.

If not found, it means no cuts have been generated for this value yet. In that case return a trivial cut set.

Definition at line 771 of file CutRewriter.cpp.

References assert(), cutSets, and getAsTrivialCut().

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

◆ takeVector()

llvm::MapVector< Value, std::unique_ptr< CutSet > > CutEnumerator::takeVector ( )

Move ownership of all cut sets to caller.

After calling this, the enumerator is left in an empty state.

Definition at line 649 of file CutRewriter.cpp.

References cutSets.

Referenced by circt::synth::CutRewriter::runBottomUpRewrite().

◆ visit()

LogicalResult CutEnumerator::visit ( Operation *  op)
private

Visit a single operation and generate cuts for it.

Definition at line 655 of file CutRewriter.cpp.

References isSupportedLogicOp(), and visitLogicOp().

Referenced by enumerateCuts().

◆ visitLogicOp()

LogicalResult CutEnumerator::visitLogicOp ( Operation *  logicOp)
private

Visit a combinational logic operation and generate cuts.

This handles the core cut enumeration logic for operations like AND, OR, XOR, etc.

Definition at line 664 of file CutRewriter.cpp.

References assert(), createNewCutSet(), getAsTrivialCut(), getCutSet(), circt::synth::Cut::getInputSize(), matchCut, circt::synth::CutRewriterOptions::maxCutInputSize, circt::synth::Cut::mergeWith(), options, and circt::synth::Cut::reRoot().

Referenced by visit().

Member Data Documentation

◆ cutSets

llvm::MapVector<Value, std::unique_ptr<CutSet> > circt::synth::CutEnumerator::cutSets
private

Maps values to their associated cut sets.

Definition at line 310 of file CutRewriter.h.

Referenced by clear(), createNewCutSet(), dump(), getCutSet(), and takeVector().

◆ matchCut

llvm::function_ref<std::optional<MatchedPattern>(const Cut &)> circt::synth::CutEnumerator::matchCut
private

Function to match cuts against available patterns.

Set during enumeration and used when finalizing cut sets.

Definition at line 317 of file CutRewriter.h.

Referenced by enumerateCuts(), and visitLogicOp().

◆ options

const CutRewriterOptions& circt::synth::CutEnumerator::options
private

Configuration options for cut enumeration.

Definition at line 313 of file CutRewriter.h.

Referenced by visitLogicOp().


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