CIRCT 22.0.0git
Loading...
Searching...
No Matches
CutRewriter.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This header file defines a general cut-based rewriting framework for
10// combinational logic optimization. The framework uses NPN-equivalence matching
11// with area and delay metrics to rewrite cuts (subgraphs) in combinational
12// circuits with optimal patterns.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef CIRCT_DIALECT_SYNTH_TRANSFORMS_CUT_REWRITER_H
17#define CIRCT_DIALECT_SYNTH_TRANSFORMS_CUT_REWRITER_H
18
20#include "circt/Support/LLVM.h"
22#include "mlir/IR/Operation.h"
23#include "llvm/ADT/APInt.h"
24#include "llvm/ADT/SetVector.h"
25#include "llvm/ADT/SmallVector.h"
26#include "llvm/Support/LogicalResult.h"
27#include "llvm/Support/raw_ostream.h"
28#include <memory>
29#include <optional>
30
31namespace circt {
32namespace synth {
33// Type for representing delays in the circuit. It's user's responsibility to
34// use consistent units, i.e., all delays should be in the same unit (usually
35// femtoseconds, but not limited to it).
36using DelayType = int64_t;
37
38/// Maximum number of inputs supported for truth table generation.
39/// This limit prevents excessive memory usage as truth table size grows
40/// exponentially with the number of inputs (2^n entries).
41static constexpr unsigned maxTruthTableInputs = 16;
42
43// This is a helper function to sort operations topologically in a logic
44// network. This is necessary for cut rewriting to ensure that operations are
45// processed in the correct order, respecting dependencies.
46LogicalResult topologicallySortLogicNetwork(mlir::Operation *op);
47
48// Get the truth table for a specific operation within a block.
49// Block must be a SSACFG or topologically sorted.
50FailureOr<BinaryTruthTable> getTruthTable(ValueRange values, Block *block);
51
52//===----------------------------------------------------------------------===//
53// Cut Data Structures
54//===----------------------------------------------------------------------===//
55
56// Forward declarations
58class CutRewriter;
61
62/// Represents a cut that has been successfully matched to a rewriting pattern.
63///
64/// This class encapsulates the result of matching a cut against a rewriting
65/// pattern during optimization. It stores the matched pattern, the
66/// cut that was matched, and timing information needed for optimization.
68private:
69 const CutRewritePattern *pattern = nullptr; ///< The matched library pattern
70 SmallVector<DelayType, 1>
71 arrivalTimes; ///< Arrival times of outputs from this pattern
72
73public:
74 /// Default constructor creates an invalid matched pattern.
75 MatchedPattern() = default;
76
77 /// Constructor for a valid matched pattern.
79 SmallVector<DelayType, 1> arrivalTimes)
80 : pattern(pattern), arrivalTimes(std::move(arrivalTimes)) {}
81
82 /// Get the arrival time of signals through this pattern.
83 DelayType getArrivalTime(unsigned outputIndex) const;
84 ArrayRef<DelayType> getArrivalTimes() const;
86
87 /// Get the library pattern that was matched.
88 const CutRewritePattern *getPattern() const;
89
90 /// Get the area cost of using this pattern.
91 double getArea() const;
92
93 /// Get the delay between specific input and output pins.
94 DelayType getDelay(unsigned inputIndex, unsigned outputIndex) const;
95};
96
97/// Represents a cut in the combinational logic network.
98///
99/// A cut is a subset of nodes in the combinational logic that forms a complete
100/// subgraph with a single output. It represents a portion of the circuit that
101/// can potentially be replaced with a single library gate or pattern.
102///
103/// The cut contains:
104/// - Input values: The boundary between the cut and the rest of the circuit
105/// - Operations: The logic operations within the cut boundary
106/// - Root operation: The output-driving operation of the cut
107///
108/// Cuts are used in combinational logic optimization to identify regions that
109/// can be optimized and replaced with more efficient implementations.
110class Cut {
111 /// Cached truth table for this cut.
112 /// Computed lazily when first accessed to avoid unnecessary computation.
113 mutable std::optional<BinaryTruthTable> truthTable;
114
115 /// Cached NPN canonical form for this cut.
116 /// Computed lazily from the truth table when first accessed.
117 mutable std::optional<NPNClass> npnClass;
118
119 std::optional<MatchedPattern> matchedPattern;
120
121public:
122 /// External inputs to this cut (cut boundary).
123 /// These are the values that flow into the cut from outside.
124 llvm::SmallSetVector<mlir::Value, 4> inputs;
125
126 /// Operations contained within this cut.
127 /// Stored in topological order with the root operation at the end.
128 llvm::SmallSetVector<mlir::Operation *, 4> operations;
129
130 /// Check if this cut represents a trivial cut.
131 /// A trivial cut has no internal operations and exactly one input.
132 bool isTrivialCut() const;
133
134 /// Get the root operation of this cut.
135 /// The root operation produces the output of the cut.
136 mlir::Operation *getRoot() const;
137
138 void dump(llvm::raw_ostream &os) const;
139
140 /// Merge this cut with another cut to form a new cut.
141 /// The new cut combines the operations from both cuts with the given root.
142 Cut mergeWith(const Cut &other, Operation *root) const;
143 Cut reRoot(Operation *root) const;
144
145 /// Get the number of inputs to this cut.
146 unsigned getInputSize() const;
147
148 /// Get the number of operations in this cut.
149 unsigned getCutSize() const;
150
151 /// Get the number of outputs from root operation.
152 unsigned getOutputSize() const;
153
154 /// Get the truth table for this cut.
155 /// The truth table represents the boolean function computed by this cut.
156 const BinaryTruthTable &getTruthTable() const;
157
158 /// Get the NPN canonical form for this cut.
159 /// This is used for efficient pattern matching against library components.
160 const NPNClass &getNPNClass() const;
161
162 /// Get the permutated inputs for this cut based on the given pattern NPN.
163 void getPermutatedInputs(const NPNClass &patternNPN,
164 SmallVectorImpl<Value> &permutedInputs) const;
165
166 /// Matched pattern for this cut.
170
171 /// Get the matched pattern for this cut.
172 const std::optional<MatchedPattern> &getMatchedPattern() const {
173 return matchedPattern;
174 }
175};
176
177/// Manages a collection of cuts for a single logic node using priority cuts
178/// algorithm.
179///
180/// Each node in the combinational logic network can have multiple cuts
181/// representing different ways to group it with surrounding logic. The CutSet
182/// manages these cuts and selects the best one based on the optimization
183/// strategy (area or timing).
184///
185/// The priority cuts algorithm maintains a bounded set of the most promising
186/// cuts to avoid exponential explosion while ensuring good optimization
187/// results.
188class CutSet {
189private:
190 llvm::SmallVector<Cut, 4> cuts; ///< Collection of cuts for this node
191 Cut *bestCut = nullptr;
192 bool isFrozen = false; ///< Whether cut set is finalized
193
194public:
195 /// Check if this cut set has a valid matched pattern.
196 bool isMatched() const { return bestCut; }
197
198 /// Get the cut associated with the best matched pattern.
199 Cut *getBestMatchedCut() const;
200
201 /// Finalize the cut set by removing duplicates and selecting the best
202 /// pattern.
203 ///
204 /// This method:
205 /// 1. Removes duplicate cuts based on inputs and root operation
206 /// 2. Limits the number of cuts to prevent exponential growth
207 /// 3. Matches each cut against available patterns
208 /// 4. Selects the best pattern based on the optimization strategy
209 void finalize(
210 const CutRewriterOptions &options,
211 llvm::function_ref<std::optional<MatchedPattern>(const Cut &)> matchCut);
212
213 /// Get the number of cuts in this set.
214 unsigned size() const;
215
216 /// Add a new cut to this set.
217 /// NOTE: The cut set must not be frozen
218 void addCut(Cut cut);
219
220 /// Get read-only access to all cuts in this set.
221 ArrayRef<Cut> getCuts() const;
222};
223
224/// Configuration options for the cut-based rewriting algorithm.
225///
226/// These options control various aspects of the rewriting process including
227/// optimization strategy, resource limits, and algorithmic parameters.
229 /// Optimization strategy (area vs. timing).
231
232 /// Maximum number of inputs allowed for any cut.
233 /// Larger cuts provide more optimization opportunities but increase
234 /// computational complexity exponentially.
236
237 /// Maximum number of cuts to maintain per logic node.
238 /// The priority cuts algorithm keeps only the most promising cuts
239 /// to prevent exponential explosion.
241
242 /// Fail if there is a root operation that has no matching pattern.
243 bool allowNoMatch = false;
244
245 /// Put arrival times to rewritten operations.
246 bool attachDebugTiming = false;
247
248 /// Run priority cuts enumeration and dump the cut sets.
249 bool testPriorityCuts = false;
250};
251
252//===----------------------------------------------------------------------===//
253// Cut Enumeration Engine
254//===----------------------------------------------------------------------===//
255
256/// Cut enumeration engine for combinational logic networks.
257///
258/// The CutEnumerator is responsible for generating cuts for each node in a
259/// combinational logic network. It uses a priority cuts algorithm to maintain a
260/// bounded set of promising cuts while avoiding exponential explosion.
261///
262/// The enumeration process works by:
263/// 1. Visiting nodes in topological order
264/// 2. For each node, combining cuts from its inputs
265/// 3. Matching generated cuts against available patterns
266/// 4. Maintaining only the most promising cuts per node
268public:
269 /// Constructor for cut enumerator.
271
272 /// Enumerate cuts for all nodes in the given module.
273 ///
274 /// This is the main entry point that orchestrates the cut enumeration
275 /// process. It visits all operations in the module and generates cuts
276 /// for combinational logic operations.
277 LogicalResult enumerateCuts(
278 Operation *topOp,
279 llvm::function_ref<std::optional<MatchedPattern>(const Cut &)> matchCut =
280 [](const Cut &) { return std::nullopt; });
281
282 /// Create a new cut set for a value.
283 /// The value must not already have a cut set.
284 CutSet *createNewCutSet(Value value);
285
286 /// Get the cut set for a specific value.
287 /// If not found, it means no cuts have been generated for this value yet.
288 /// In that case return a trivial cut set.
289 const CutSet *getCutSet(Value value);
290
291 /// Move ownership of all cut sets to caller.
292 /// After calling this, the enumerator is left in an empty state.
293 llvm::MapVector<Value, std::unique_ptr<CutSet>> takeVector();
294
295 /// Clear all cut sets and reset the enumerator.
296 void clear();
297
298 void dump() const;
299
300private:
301 /// Visit a single operation and generate cuts for it.
302 LogicalResult visit(Operation *op);
303
304 /// Visit a combinational logic operation and generate cuts.
305 /// This handles the core cut enumeration logic for operations
306 /// like AND, OR, XOR, etc.
307 LogicalResult visitLogicOp(Operation *logicOp);
308
309 /// Maps values to their associated cut sets.
310 llvm::MapVector<Value, std::unique_ptr<CutSet>> cutSets;
311
312 /// Configuration options for cut enumeration.
314
315 /// Function to match cuts against available patterns.
316 /// Set during enumeration and used when finalizing cut sets.
317 llvm::function_ref<std::optional<MatchedPattern>(const Cut &)> matchCut;
318};
319
320/// Base class for cut rewriting patterns used in combinational logic
321/// optimization.
322///
323/// A CutRewritePattern represents a library component or optimization pattern
324/// that can replace cuts in the combinational logic network. Each pattern
325/// defines:
326/// - How to recognize matching cuts
327/// - How to transform/replace the matched cuts
328/// - Area and timing characteristics
329///
330/// Patterns can use truth table matching for efficient recognition or
331/// implement custom matching logic for more complex cases.
333 CutRewritePattern(mlir::MLIRContext *context) : context(context) {}
334 /// Virtual destructor for base class.
335 virtual ~CutRewritePattern() = default;
336
337 /// Check if a cut matches this pattern.
338 ///
339 /// This method is called to determine if a cut can be replaced by this
340 /// pattern. If useTruthTableMatcher() returns true, this method is only
341 /// called for cuts with matching truth tables.
342 virtual bool match(const Cut &cut) const = 0;
343
344 /// Specify truth tables that this pattern can match.
345 ///
346 /// If this method returns true, the pattern matcher will use truth table
347 /// comparison for efficient pre-filtering. Only cuts with matching truth
348 /// tables will be passed to the match() method. If it returns false, the
349 /// pattern will be checked against all cuts regardless of their truth tables.
350 /// This is useful for patterns that match regardless of their truth tables,
351 /// such as LUT-based patterns.
352 virtual bool
353 useTruthTableMatcher(SmallVectorImpl<NPNClass> &matchingNPNClasses) const;
354
355 /// Return a new operation that replaces the matched cut.
356 ///
357 /// Unlike MLIR's RewritePattern framework which allows arbitrary in-place
358 /// modifications, this method creates a new operation to replace the matched
359 /// cut rather than modifying existing operations. This constraint exists
360 /// because the cut enumerator maintains references to operations throughout
361 /// the circuit, making it safe to only replace the root operation of each
362 /// cut while preserving all other operations unchanged.
363 virtual FailureOr<Operation *> rewrite(mlir::OpBuilder &builder,
364 Cut &cut) const = 0;
365
366 /// Get the area cost of this pattern.
367 virtual double getArea() const = 0;
368
369 /// Get the delay between specific input and output.
370 /// NOTE: The input index is already permuted according to the pattern's
371 /// input permutation, so it's not necessary to account for it here.
372 virtual DelayType getDelay(unsigned inputIndex,
373 unsigned outputIndex) const = 0;
374
375 /// Get the number of outputs this pattern produces.
376 virtual unsigned getNumOutputs() const = 0;
377
378 /// Get the name of this pattern. Used for debugging.
379 virtual StringRef getPatternName() const { return "<unnamed>"; }
380
381 /// Get location for this pattern(optional).
382 virtual LocationAttr getLoc() const { return mlir::UnknownLoc::get(context); }
383
384 mlir::MLIRContext *getContext() const { return context; }
385
386private:
387 mlir::MLIRContext *context;
388};
389
390/// Manages a collection of rewriting patterns for combinational logic
391/// optimization.
392///
393/// This class organizes and provides efficient access to rewriting patterns
394/// used during cut-based optimization. It maintains:
395/// - A collection of all available patterns
396/// - Fast lookup tables for truth table-based matching
397/// - Separation of truth table vs. custom matching patterns
398///
399/// The pattern set is used by the CutRewriter to find suitable replacements
400/// for cuts in the combinational logic network.
402public:
403 /// Constructor that takes ownership of the provided patterns.
404 ///
405 /// During construction, patterns are analyzed and organized for efficient
406 /// lookup. Truth table matchers are indexed by their NPN canonical forms.
408 llvm::SmallVector<std::unique_ptr<CutRewritePattern>, 4> patterns);
409
410private:
411 /// Owned collection of all rewriting patterns.
412 llvm::SmallVector<std::unique_ptr<CutRewritePattern>, 4> patterns;
413
414 /// Fast lookup table mapping NPN canonical forms to matching patterns.
415 /// Each entry maps a truth table and input size to patterns that can handle
416 /// it.
417 DenseMap<std::pair<APInt, unsigned>,
418 SmallVector<std::pair<NPNClass, const CutRewritePattern *>>>
420
421 /// Patterns that use custom matching logic instead of truth tables.
422 /// These patterns are checked against every cut.
423 SmallVector<const CutRewritePattern *, 4> nonTruthTablePatterns;
424
425 /// CutRewriter needs access to internal data structures for pattern matching.
426 friend class CutRewriter;
427};
428
429/// Main cut-based rewriting algorithm for combinational logic optimization.
430///
431/// The CutRewriter implements a cut-based rewriting algorithm that:
432/// 1. Enumerates cuts in the combinational logic network using a priority cuts
433/// algorithm
434/// 2. Matches cuts against available rewriting patterns
435/// 3. Selects optimal patterns based on area or timing objectives
436/// 4. Rewrites the circuit using the selected patterns
437///
438/// The algorithm processes the network in topological order, building up cut
439/// sets for each node and selecting the best implementation based on the
440/// specified optimization strategy.
441///
442/// Usage example:
443/// ```cpp
444/// CutRewriterOptions options;
445/// options.strategy = OptimizationStrategy::Area;
446/// options.maxCutInputSize = 4;
447/// options.maxCutSizePerRoot = 8;
448///
449/// CutRewritePatternSet patterns(std::move(optimizationPatterns));
450/// CutRewriter rewriter(module, options, patterns);
451///
452/// if (failed(rewriter.run())) {
453/// // Handle rewriting failure
454/// }
455/// ```
457public:
458 /// Constructor for the cut rewriter.
461
462 /// Execute the complete cut-based rewriting algorithm.
463 ///
464 /// This method orchestrates the entire rewriting process:
465 /// 1. Enumerate cuts for all nodes in the combinational logic
466 /// 2. Match cuts against available patterns
467 /// 3. Select optimal patterns based on strategy
468 /// 4. Rewrite the circuit with selected patterns
469 LogicalResult run(Operation *topOp);
470
471private:
472 /// Enumerate cuts for all nodes in the given module.
473 /// Note: This preserves module boundaries and does not perform
474 /// rewriting across the hierarchy.
475 LogicalResult enumerateCuts(Operation *topOp);
476
477 /// Find patterns that match a cut's truth table.
478 ArrayRef<std::pair<NPNClass, const CutRewritePattern *>>
479 getMatchingPatternsFromTruthTable(const Cut &cut) const;
480
481 /// Match a cut against available patterns and compute arrival time.
482 std::optional<MatchedPattern> patternMatchCut(const Cut &cut);
483
484 /// Perform the actual circuit rewriting using selected patterns.
485 LogicalResult runBottomUpRewrite(Operation *topOp);
486
487 /// Configuration options
489
490 /// Available rewriting patterns
492
494};
495
496} // namespace synth
497} // namespace circt
498
499#endif // CIRCT_DIALECT_SYNTH_TRANSFORMS_CUT_REWRITER_H
RewritePatternSet pattern
Cut enumeration engine for combinational logic networks.
LogicalResult visit(Operation *op)
Visit a single operation and generate cuts for it.
const CutRewriterOptions & options
Configuration options for cut enumeration.
llvm::MapVector< Value, std::unique_ptr< CutSet > > cutSets
Maps values to their associated cut sets.
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.
void clear()
Clear all cut sets and reset the enumerator.
llvm::function_ref< std::optional< MatchedPattern >(const Cut &)> matchCut
Function to match cuts against available patterns.
LogicalResult visitLogicOp(Operation *logicOp)
Visit a combinational logic operation and generate cuts.
llvm::MapVector< Value, std::unique_ptr< CutSet > > takeVector()
Move ownership of all cut sets to caller.
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.
Manages a collection of rewriting patterns for combinational logic optimization.
llvm::SmallVector< std::unique_ptr< CutRewritePattern >, 4 > patterns
Owned collection of all rewriting patterns.
DenseMap< std::pair< APInt, unsigned >, SmallVector< std::pair< NPNClass, const CutRewritePattern * > > > npnToPatternMap
Fast lookup table mapping NPN canonical forms to matching patterns.
SmallVector< const CutRewritePattern *, 4 > nonTruthTablePatterns
Patterns that use custom matching logic instead of truth tables.
Main cut-based rewriting algorithm for combinational logic optimization.
const CutRewriterOptions & options
Configuration options.
ArrayRef< std::pair< NPNClass, const CutRewritePattern * > > getMatchingPatternsFromTruthTable(const Cut &cut) const
Find patterns that match a cut's truth table.
std::optional< MatchedPattern > patternMatchCut(const Cut &cut)
Match a cut against available patterns and compute arrival time.
LogicalResult enumerateCuts(Operation *topOp)
Enumerate cuts for all nodes in the given module.
LogicalResult run(Operation *topOp)
Execute the complete cut-based rewriting algorithm.
const CutRewritePatternSet & patterns
Available rewriting patterns.
CutEnumerator cutEnumerator
CutRewriter(const CutRewriterOptions &options, CutRewritePatternSet &patterns)
Constructor for the cut rewriter.
LogicalResult runBottomUpRewrite(Operation *topOp)
Perform the actual circuit rewriting using selected patterns.
Manages a collection of cuts for a single logic node using priority cuts algorithm.
Cut * getBestMatchedCut() const
Get the cut associated with the best matched pattern.
llvm::SmallVector< Cut, 4 > cuts
Collection of cuts for this node.
void addCut(Cut cut)
Add a new cut to this set.
unsigned size() const
Get the number of cuts in this set.
void finalize(const CutRewriterOptions &options, llvm::function_ref< std::optional< MatchedPattern >(const Cut &)> matchCut)
Finalize the cut set by removing duplicates and selecting the best pattern.
bool isMatched() const
Check if this cut set has a valid matched pattern.
bool isFrozen
Whether cut set is finalized.
ArrayRef< Cut > getCuts() const
Get read-only access to all cuts in this set.
Represents a cut in the combinational logic network.
std::optional< NPNClass > npnClass
Cached NPN canonical form for this cut.
std::optional< MatchedPattern > matchedPattern
const std::optional< MatchedPattern > & getMatchedPattern() const
Get the matched pattern for this cut.
llvm::SmallSetVector< mlir::Operation *, 4 > operations
Operations contained within this cut.
unsigned getOutputSize() const
Get the number of outputs from root operation.
void getPermutatedInputs(const NPNClass &patternNPN, SmallVectorImpl< Value > &permutedInputs) const
Get the permutated inputs for this cut based on the given pattern NPN.
const NPNClass & getNPNClass() const
Get the NPN canonical form for this cut.
mlir::Operation * getRoot() const
Get the root operation of this cut.
llvm::SmallSetVector< mlir::Value, 4 > inputs
External inputs to this cut (cut boundary).
void dump(llvm::raw_ostream &os) const
const BinaryTruthTable & getTruthTable() const
Get the truth table for this cut.
std::optional< BinaryTruthTable > truthTable
Cached truth table for this cut.
Cut mergeWith(const Cut &other, Operation *root) const
Merge this cut with another cut to form a new cut.
unsigned getInputSize() const
Get the number of inputs to this cut.
void setMatchedPattern(MatchedPattern pattern)
Matched pattern for this cut.
unsigned getCutSize() const
Get the number of operations in this cut.
bool isTrivialCut() const
Check if this cut represents a trivial cut.
Cut reRoot(Operation *root) const
Represents a cut that has been successfully matched to a rewriting pattern.
Definition CutRewriter.h:67
DelayType getArrivalTime(unsigned outputIndex) const
Get the arrival time of signals through this pattern.
MatchedPattern(const CutRewritePattern *pattern, SmallVector< DelayType, 1 > arrivalTimes)
Constructor for a valid matched pattern.
Definition CutRewriter.h:78
DelayType getDelay(unsigned inputIndex, unsigned outputIndex) const
Get the delay between specific input and output pins.
ArrayRef< DelayType > getArrivalTimes() const
const CutRewritePattern * pattern
The matched library pattern.
Definition CutRewriter.h:69
DelayType getWorstOutputArrivalTime() const
double getArea() const
Get the area cost of using this pattern.
MatchedPattern()=default
Default constructor creates an invalid matched pattern.
const CutRewritePattern * getPattern() const
Get the library pattern that was matched.
SmallVector< DelayType, 1 > arrivalTimes
Arrival times of outputs from this pattern.
Definition CutRewriter.h:71
OptimizationStrategy
Optimization strategy.
Definition SynthPasses.h:24
FailureOr< BinaryTruthTable > getTruthTable(ValueRange values, Block *block)
int64_t DelayType
Definition CutRewriter.h:36
static constexpr unsigned maxTruthTableInputs
Maximum number of inputs supported for truth table generation.
Definition CutRewriter.h:41
LogicalResult topologicallySortLogicNetwork(mlir::Operation *op)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition synth.py:1
Represents a boolean function as a truth table.
Definition NPNClass.h:38
Represents the canonical form of a boolean function under NPN equivalence.
Definition NPNClass.h:103
Base class for cut rewriting patterns used in combinational logic optimization.
virtual StringRef getPatternName() const
Get the name of this pattern. Used for debugging.
virtual ~CutRewritePattern()=default
Virtual destructor for base class.
virtual DelayType getDelay(unsigned inputIndex, unsigned outputIndex) const =0
Get the delay between specific input and output.
virtual bool useTruthTableMatcher(SmallVectorImpl< NPNClass > &matchingNPNClasses) const
Specify truth tables that this pattern can match.
mlir::MLIRContext * getContext() const
mlir::MLIRContext * context
virtual FailureOr< Operation * > rewrite(mlir::OpBuilder &builder, Cut &cut) const =0
Return a new operation that replaces the matched cut.
CutRewritePattern(mlir::MLIRContext *context)
virtual double getArea() const =0
Get the area cost of this pattern.
virtual unsigned getNumOutputs() const =0
Get the number of outputs this pattern produces.
virtual bool match(const Cut &cut) const =0
Check if a cut matches this pattern.
virtual LocationAttr getLoc() const
Get location for this pattern(optional).
Configuration options for the cut-based rewriting algorithm.
unsigned maxCutInputSize
Maximum number of inputs allowed for any cut.
unsigned maxCutSizePerRoot
Maximum number of cuts to maintain per logic node.
bool allowNoMatch
Fail if there is a root operation that has no matching pattern.
bool attachDebugTiming
Put arrival times to rewritten operations.
OptimizationStrategy strategy
Optimization strategy (area vs. timing).
bool testPriorityCuts
Run priority cuts enumeration and dump the cut sets.