13#ifndef CIRCT_DIALECT_SYNTH_SYNTHOPS_H
14#define CIRCT_DIALECT_SYNTH_SYNTHOPS_H
19#include "mlir/IR/Attributes.h"
20#include "mlir/IR/Builders.h"
21#include "mlir/IR/BuiltinOps.h"
22#include "mlir/IR/BuiltinTypes.h"
23#include "mlir/IR/Dialect.h"
24#include "mlir/IR/Operation.h"
25#include "mlir/Interfaces/InferTypeOpInterface.h"
26#include "mlir/Interfaces/SideEffectInterfaces.h"
27#include "mlir/Rewrite/PatternApplicator.h"
30#include "circt/Dialect/Synth/Synth.h.inc"
32#include "llvm/ADT/PriorityQueue.h"
48 llvm::function_ref<
bool(mlir::Value, mlir::Operation *)> isOperandReady);
59 llvm::PointerIntPair<mlir::Value, 1, bool>
value;
104 llvm::function_ref<T(T, T)> combine) {
105 assert(!elements.empty() &&
"Cannot build tree from empty elements");
107 if (elements.size() == 1)
109 if (elements.size() == 2)
110 return combine(elements[0], elements[1]);
113 llvm::PriorityQueue<T, std::vector<T>, std::greater<T>> pq(elements.begin(),
117 while (pq.size() > 1) {
124 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.
void populateVariadicXorInverterLoweringPatterns(mlir::RewritePatternSet &patterns)
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...
void populateVariadicAndInverterLoweringPatterns(mlir::RewritePatternSet &patterns)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.