CIRCT 22.0.0git
|
Cut enumeration engine for combinational logic networks. More...
#include <CutRewriter.h>
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. | |
CutSet * | createNewCutSet (Value value) |
Create a new cut set for a value. | |
const CutSet * | getCutSet (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 CutRewriterOptions & | options |
Configuration options for cut enumeration. | |
llvm::function_ref< std::optional< MatchedPattern >(const Cut &)> | matchCut |
Function to match cuts against available patterns. | |
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:
Definition at line 267 of file CutRewriter.h.
|
explicit |
Constructor for cut enumerator.
Definition at line 639 of file CutRewriter.cpp.
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().
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().
void CutEnumerator::dump | ( | ) | const |
Definition at line 831 of file CutRewriter.cpp.
References cutSets, getTestVariableName(), and pattern.
Referenced by circt::synth::CutRewriter::run().
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().
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().
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().
|
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().
|
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().
|
private |
Maps values to their associated cut sets.
Definition at line 310 of file CutRewriter.h.
Referenced by clear(), createNewCutSet(), dump(), getCutSet(), and takeVector().
|
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().
|
private |
Configuration options for cut enumeration.
Definition at line 313 of file CutRewriter.h.
Referenced by visitLogicOp().