17#ifndef CIRCT_ANALYSIS_AIG_ANALYSIS_H
18#define CIRCT_ANALYSIS_AIG_ANALYSIS_H
23#include "mlir/IR/BuiltinOps.h"
24#include "mlir/IR/MLIRContext.h"
25#include "llvm/ADT/ArrayRef.h"
26#include "llvm/ADT/ImmutableList.h"
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/Support/JSON.h"
52 void print(llvm::raw_ostream &os)
const;
72 void Profile(llvm::FoldingSetNodeID &ID)
const {
73 for (
auto &inst :
object.instancePath) {
74 ID.AddPointer(inst.getAsOpaquePointer());
76 ID.AddPointer(
object.value.getAsOpaquePointer());
77 ID.AddInteger(
object.bitPos);
72 void Profile(llvm::FoldingSetNodeID &ID)
const {
…}
81 void print(llvm::raw_ostream &os)
const;
92 int64_t
delay = 0, llvm::ImmutableList<DebugPoint>
history = {})
100 void print(llvm::raw_ostream &os)
const;
103 llvm::ImmutableListFactory<DebugPoint> *debugPointFactory,
121 using OutputPort = std::tuple<hw::HWModuleOp, size_t, size_t>;
139 return std::get<OutputPort>(
fanOut);
152 void print(llvm::raw_ostream &os);
159 llvm::ImmutableListFactory<DebugPoint> *debugPointFactory,
192 SmallVectorImpl<DataflowPath> &results)
const;
209 SmallVectorImpl<DataflowPath> &results,
210 bool elaboratePaths =
false)
const;
216 StringAttr moduleName, SmallVectorImpl<DataflowPath> &results)
const;
222 StringAttr moduleName, SmallVectorImpl<DataflowPath> &results)
const;
230 SmallVectorImpl<DataflowPath> &results,
231 bool elaboratePaths =
false)
const;
246 return "aig.longest-path-analysis-top";
273 llvm::SmallVector<DataflowPath, 64>
paths;
293 std::tuple<circt::igraph::InstancePath, mlir::Value, size_t>>;
296 auto [path, value, bitPos] = Info::getEmptyKey();
297 return Object(path, value, bitPos);
301 auto [path, value, bitPos] = Info::getTombstoneKey();
302 return Object(path, value, bitPos);
305 return Info::getHashValue(
306 {
object.instancePath,
object.value,
object.bitPos});
const OpenPath & getPath() const
std::tuple< hw::HWModuleOp, size_t, size_t > OutputPort
const OutputPort & getFanOutAsPort() const
const llvm::ImmutableList< DebugPoint > & getHistory() const
const Object & getFanOutAsObject() const
std::variant< Object, OutputPort > FanOutType
const FanOutType & getFanOut() const
DataflowPath & prependPaths(circt::igraph::InstancePathCache &cache, llvm::ImmutableListFactory< DebugPoint > *debugPointFactory, circt::igraph::InstancePath path)
DataflowPath(OutputPort fanOut, OpenPath fanIn, hw::HWModuleOp root)
const Object & getFanIn() const
DataflowPath(Object fanOut, OpenPath fanIn, hw::HWModuleOp root)
void printFanOut(llvm::raw_ostream &os)
void print(llvm::raw_ostream &os)
hw::HWModuleOp getRoot() const
void setDelay(int64_t delay)
LongestPathAnalysisWithTrace(Operation *moduleOp, mlir::AnalysisManager &am)
LogicalResult getResults(Value value, size_t bitPos, SmallVectorImpl< DataflowPath > &results) const
LogicalResult getClosedPaths(StringAttr moduleName, SmallVectorImpl< DataflowPath > &results, bool elaboratePaths=false) const
int64_t getMaxDelay(Value value) const
int64_t getAverageMaxDelay(Value value) const
LogicalResult getAllPaths(StringAttr moduleName, SmallVectorImpl< DataflowPath > &results, bool elaboratePaths=false) const
MLIRContext * getContext() const
LogicalResult getOpenPathsFromInternalToOutputPorts(StringAttr moduleName, SmallVectorImpl< DataflowPath > &results) const
static StringRef getTopModuleNameAttrName()
llvm::ArrayRef< hw::HWModuleOp > getTopModules() const
bool isAnalysisAvailable(StringAttr moduleName) const
LogicalResult getOpenPathsFromInputPortsToInternal(StringAttr moduleName, SmallVectorImpl< DataflowPath > &results) const
const DataflowPath & getPath(unsigned index) const
void sortAndDropNonCriticalPathsPerFanOut()
MLIRContext * getContext() const
void sortInDescendingOrder()
LongestPathCollection(MLIRContext *ctx)
llvm::SmallVector< DataflowPath, 64 > paths
This graph tracks modules and where they are instantiated.
An instance path composed of a series of instances.
llvm::json::Value toJSON(const circt::aig::DataflowPath &path)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void Profile(llvm::FoldingSetNodeID &ID) const
DebugPoint(circt::igraph::InstancePath path, Value value, size_t bitPos, int64_t delay=0, StringRef comment="")
void print(llvm::raw_ostream &os) const
circt::igraph::InstancePath instancePath
Object & prependPaths(circt::igraph::InstancePathCache &cache, circt::igraph::InstancePath path)
StringAttr getName() const
bool operator==(const Object &other) const
void print(llvm::raw_ostream &os) const
Object(circt::igraph::InstancePath path, Value value, size_t bitPos)
const Object & getFanIn() const
void print(llvm::raw_ostream &os) const
OpenPath(circt::igraph::InstancePath path, Value value, size_t bitPos, int64_t delay=0, llvm::ImmutableList< DebugPoint > history={})
OpenPath & prependPaths(circt::igraph::InstancePathCache &cache, llvm::ImmutableListFactory< DebugPoint > *debugPointFactory, circt::igraph::InstancePath path)
llvm::ImmutableList< DebugPoint > history
const llvm::ImmutableList< DebugPoint > & getHistory() const
A data structure that caches and provides paths to module instances in the IR.
static Object getTombstoneKey()
static llvm::hash_code getHashValue(Object object)
static Object getEmptyKey()
static bool isEqual(const Object &a, const Object &b)