13#ifndef CIRCT_DIALECT_SYNTH_SYNTHOPS_H
14#define CIRCT_DIALECT_SYNTH_SYNTHOPS_H
18#include "mlir/IR/Attributes.h"
19#include "mlir/IR/Builders.h"
20#include "mlir/IR/BuiltinOps.h"
21#include "mlir/IR/BuiltinTypes.h"
22#include "mlir/IR/Dialect.h"
23#include "mlir/IR/Operation.h"
24#include "mlir/Interfaces/InferTypeOpInterface.h"
25#include "mlir/Interfaces/SideEffectInterfaces.h"
26#include "mlir/Rewrite/PatternApplicator.h"
29#include "circt/Dialect/Synth/Synth.h.inc"
31#include "llvm/ADT/PriorityQueue.h"
40 mlir::PatternRewriter &rewriter)
const override;
50 llvm::function_ref<
bool(mlir::Value, mlir::Operation *)> isOperandReady);
61 llvm::PointerIntPair<mlir::Value, 1, bool>
value;
106 llvm::function_ref<T(T, T)> combine) {
107 assert(!elements.empty() &&
"Cannot build tree from empty elements");
109 if (elements.size() == 1)
111 if (elements.size() == 2)
112 return combine(elements[0], elements[1]);
115 llvm::PriorityQueue<T, std::vector<T>, std::greater<T>> pq(elements.begin(),
119 while (pq.size() > 1) {
126 T combined = combine(e1, e2);
assert(baseType &&"element must be base type")
Helper class for delay-aware tree building.
ValueWithArrivalTime(mlir::Value value, int64_t arrivalTime, bool invert, size_t valueNumbering=0)
mlir::Value getValue() const
ValueWithArrivalTime & flipInversion()
size_t valueNumbering
Value numbering for deterministic ordering when arrival times are equal.
int64_t getArrivalTime() const
int64_t arrivalTime
The arrival time (delay) of this value in the circuit.
llvm::PointerIntPair< mlir::Value, 1, bool > value
The value and an optional inversion flag packed together.
bool operator>(const ValueWithArrivalTime &other) const
Comparison operator for priority queue.
LogicalResult topologicallySortGraphRegionBlocks(mlir::Operation *op, llvm::function_ref< bool(mlir::Value, mlir::Operation *)> isOperandReady)
This function performs a topological sort on the operations within each block of graph regions in the...
T buildBalancedTreeWithArrivalTimes(llvm::ArrayRef< T > elements, llvm::function_ref< T(T, T)> combine)
Build a balanced binary tree using a priority queue to greedily pair elements with earliest arrival t...
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
mlir::LogicalResult matchAndRewrite(aig::AndInverterOp op, mlir::PatternRewriter &rewriter) const override