Skip to content

Commit f446e29

Browse files
authored
[Synth] Rename FanIn/FanOut StartPoint/EndPoint (#8976)
This commit renames fan-in/fan-out with start_point/end_point in LongestPathAnalysis. Resolves #8967
1 parent 09f0bbe commit f446e29

File tree

16 files changed

+281
-264
lines changed

16 files changed

+281
-264
lines changed

include/circt-c/Dialect/Synth.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ MLIR_CAPI_EXPORTED int64_t
9999
synthLongestPathDataflowPathGetDelay(SynthLongestPathDataflowPath dataflowPath);
100100

101101
MLIR_CAPI_EXPORTED SynthLongestPathObject
102-
synthLongestPathDataflowPathGetFanIn(SynthLongestPathDataflowPath dataflowPath);
102+
synthLongestPathDataflowPathGetStartPoint(
103+
SynthLongestPathDataflowPath dataflowPath);
103104

104-
MLIR_CAPI_EXPORTED SynthLongestPathObject synthLongestPathDataflowPathGetFanOut(
105+
MLIR_CAPI_EXPORTED SynthLongestPathObject
106+
synthLongestPathDataflowPathGetEndPoint(
105107
SynthLongestPathDataflowPath dataflowPath);
106108

107109
MLIR_CAPI_EXPORTED SynthLongestPathHistory

include/circt/Dialect/Synth/Analysis/LongestPathAnalysis.h

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ struct DebugPoint {
9090
StringRef comment;
9191
};
9292

93-
// An OpenPath represents a path from a fan-in with an associated
93+
// An OpenPath represents a path from a start point with an associated
9494
// delay and history of debug points.
9595
struct OpenPath {
9696
OpenPath(circt::igraph::InstancePath path, Value value, size_t bitPos,
9797
int64_t delay = 0, llvm::ImmutableList<DebugPoint> history = {})
98-
: fanIn(path, value, bitPos), delay(delay), history(history) {}
98+
: startPoint(path, value, bitPos), delay(delay), history(history) {}
9999
OpenPath() = default;
100100

101-
const Object &getFanIn() const { return fanIn; }
101+
const Object &getStartPoint() const { return startPoint; }
102102
int64_t getDelay() const { return delay; }
103103
const llvm::ImmutableList<DebugPoint> &getHistory() const { return history; }
104104

@@ -108,54 +108,56 @@ struct OpenPath {
108108
llvm::ImmutableListFactory<DebugPoint> *debugPointFactory,
109109
circt::igraph::InstancePath path);
110110

111-
Object fanIn;
111+
Object startPoint;
112112
int64_t delay;
113113
// History of debug points represented by linked lists.
114-
// The head of the list is the farthest point from the fanIn.
114+
// The head of the list is the farthest point from the start point.
115115
llvm::ImmutableList<DebugPoint> history;
116116
};
117117

118-
// A DataflowPath represents a complete timing path from a fanout to a fanin
119-
// with associated delay information. This is the primary result type for
120-
// longest path analysis, containing both endpoints and path history.
118+
// A DataflowPath represents a complete timing path from a end point to a
119+
// start point with associated delay information. This is the primary result
120+
// type for longest path analysis, containing both end points and path history.
121121
class DataflowPath {
122122
public:
123-
// FanOut can be either an internal circuit object or a module output port
123+
// end point can be either an internal circuit object or a module output port
124124
// This flexibility allows representing both closed paths
125125
// (register-to-register) and open paths (register-to-output) in a unified way
126126
using OutputPort = std::tuple<hw::HWModuleOp, size_t, size_t>;
127-
using FanOutType = std::variant<Object, OutputPort>;
127+
using EndPointType = std::variant<Object, OutputPort>;
128128

129-
// Constructor for paths with Object fanout (internal circuit nodes)
130-
DataflowPath(Object fanOut, OpenPath fanIn, hw::HWModuleOp root)
131-
: fanOut(fanOut), path(fanIn), root(root) {}
129+
// Constructor for paths with Object end point (internal circuit nodes)
130+
DataflowPath(Object endPoint, OpenPath startPoint, hw::HWModuleOp root)
131+
: endPoint(endPoint), path(startPoint), root(root) {}
132132

133-
// Constructor for paths with port fanout (module output ports)
134-
DataflowPath(OutputPort fanOut, OpenPath fanIn, hw::HWModuleOp root)
135-
: fanOut(fanOut), path(fanIn), root(root) {}
133+
// Constructor for paths with port end point (module output ports)
134+
DataflowPath(OutputPort endPoint, OpenPath startPoint, hw::HWModuleOp root)
135+
: endPoint(endPoint), path(startPoint), root(root) {}
136136

137137
DataflowPath() = default;
138138

139139
int64_t getDelay() const { return path.delay; }
140-
const Object &getFanIn() const { return path.fanIn; }
141-
const FanOutType &getFanOut() const { return fanOut; }
142-
const Object &getFanOutAsObject() const { return std::get<Object>(fanOut); }
143-
const OutputPort &getFanOutAsPort() const {
144-
return std::get<OutputPort>(fanOut);
140+
const Object &getStartPoint() const { return path.startPoint; }
141+
const EndPointType &getEndPoint() const { return endPoint; }
142+
const Object &getEndPointAsObject() const {
143+
return std::get<Object>(endPoint);
144+
}
145+
const OutputPort &getEndPointAsPort() const {
146+
return std::get<OutputPort>(endPoint);
145147
}
146148
hw::HWModuleOp getRoot() const { return root; }
147149
const llvm::ImmutableList<DebugPoint> &getHistory() const {
148150
return path.history;
149151
}
150152
const OpenPath &getPath() const { return path; }
151153

152-
// Get source location for the fanout point (for diagnostics)
153-
Location getFanOutLoc();
154+
// Get source location for the end point (for diagnostics)
155+
Location getEndPointLoc();
154156

155157
void setDelay(int64_t delay) { path.delay = delay; }
156158

157159
void print(llvm::raw_ostream &os);
158-
void printFanOut(llvm::raw_ostream &os);
160+
void printEndPoint(llvm::raw_ostream &os);
159161

160162
// Path elaboration for hierarchical analysis
161163
// Prepends instance path information to create full hierarchical paths
@@ -165,9 +167,9 @@ class DataflowPath {
165167
circt::igraph::InstancePath path);
166168

167169
private:
168-
FanOutType fanOut; // Either Object or (port_index, bit_index)
169-
OpenPath path; // The actual timing path with history
170-
hw::HWModuleOp root; // Root module for this path
170+
EndPointType endPoint; // Either Object or (port_index, bit_index)
171+
OpenPath path; // The actual timing path with history
172+
hw::HWModuleOp root; // Root module for this path
171173
};
172174

173175
// JSON serialization for DataflowPath
@@ -198,7 +200,7 @@ struct LongestPathAnalysisOptions {
198200
/// are queried. Disables parallel processing.
199201
bool lazyComputation = false;
200202

201-
/// Keep only the maximum delay path per fanout point.
203+
/// Keep only the maximum delay path per end point.
202204
/// Focuses on finding maximum delays, discarding non-critical paths.
203205
/// Significantly faster and uses less memory when only delay bounds
204206
/// are needed rather than complete path enumeration.
@@ -225,7 +227,7 @@ class LongestPathAnalysis {
225227
const LongestPathAnalysisOptions &option = {});
226228
~LongestPathAnalysis();
227229

228-
// Return all longest paths to each Fanin for the given value and bit
230+
// Return all longest paths to each start point for the given value and bit
229231
// position.
230232
LogicalResult computeGlobalPaths(Value value, size_t bitPos,
231233
SmallVectorImpl<DataflowPath> &results);
@@ -248,7 +250,7 @@ class LongestPathAnalysis {
248250
// typically register-to-register paths. A closed path is a path that starts
249251
// and ends at sequential elements (registers/flip-flops), forming a complete
250252
// timing path through combinational logic. The path may cross module
251-
// boundaries but both endpoints are sequential elements, not ports.
253+
// boundaries but both end points are sequential elements, not ports.
252254
LogicalResult getClosedPaths(StringAttr moduleName,
253255
SmallVectorImpl<DataflowPath> &results,
254256
bool elaboratePaths = false) const;
@@ -344,8 +346,8 @@ class LongestPathCollection {
344346
// Sort the paths by delay in descending order.
345347
void sortInDescendingOrder();
346348

347-
// Sort and drop all paths except the longest path per fanout point.
348-
void sortAndDropNonCriticalPathsPerFanOut();
349+
// Sort and drop all paths except the longest path per end point.
350+
void sortAndDropNonCriticalPathsPerEndPoint();
349351

350352
// Merge another collection into this one.
351353
void merge(const LongestPathCollection &other);

include/circt/Dialect/Synth/Transforms/SynthPasses.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def PrintLongestPathAnalysis
9494
This pass performs longest path analysis on AIG circuits and outputs detailed
9595
timing information including:
9696
- Delay distribution statistics showing timing levels and path counts
97-
- Critical path details for the top N fanout points
97+
- Critical path details for the top N end points
9898
- Path history with intermediate debug points for detailed analysis
9999

100100
The analysis considers each AIG and-inverter operation to have unit delay and

integration_test/Bindings/Python/dialects/synth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def build_top(module):
123123
for p in collection[:2]:
124124
# CHECK-NEXT: delay 2 : out2[{{[0-9]+}}]
125125
# CHECK-NEXT: delay 2 : out2[{{[0-9]+}}]
126-
print("delay", p.delay, ":", p.fan_out)
126+
print("delay", p.delay, ":", p.end_point)
127127

128128
# CHECK-NEXT: minus index slice: True
129129
print("minus index slice:", len(collection[:-2]) == len(collection) - 2)

lib/Bindings/Python/SynthModule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ void circt::python::populateDialectSynthSubmodule(nb::module_ &m) {
9999
[](SynthLongestPathDataflowPath &self) {
100100
return synthLongestPathDataflowPathGetDelay(self);
101101
})
102-
.def_prop_ro("fan_in",
102+
.def_prop_ro("start_point",
103103
[](SynthLongestPathDataflowPath &self) {
104-
return synthLongestPathDataflowPathGetFanIn(self);
104+
return synthLongestPathDataflowPathGetStartPoint(self);
105105
})
106-
.def_prop_ro("fan_out",
106+
.def_prop_ro("end_point",
107107
[](SynthLongestPathDataflowPath &self) {
108-
return synthLongestPathDataflowPathGetFanOut(self);
108+
return synthLongestPathDataflowPathGetEndPoint(self);
109109
})
110110
.def_prop_ro("history",
111111
[](SynthLongestPathDataflowPath &self) {

lib/Bindings/Python/dialects/synth.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ def from_dict(cls, data: Dict[str, Any]) -> "DebugPoint":
116116
@dataclass
117117
class DataflowPath:
118118
"""
119-
Represents a complete dataflow path from fan-out to fan-in.
119+
Represents a complete dataflow path from end point to start point.
120120
A dataflow path captures the complete timing path through a circuit,
121-
from an output point (fan-out) back to an input point (fan-in), including
121+
from an output point (end-point) back to an input point (start-point), including
122122
all intermediate debug points and the total delay.
123123
Attributes:
124-
fan_out: The output signal/object where this path ends
124+
end_point: The output signal/object where this path ends
125125
path: The OpenPath containing the detailed path information
126126
root: The root module name for this analysis
127127
"""
@@ -134,14 +134,14 @@ def delay(self) -> int:
134134
return self._path.delay
135135

136136
@property
137-
def fan_in(self) -> Object:
137+
def start_point(self) -> Object:
138138
"""Get the input signal/object where this path begins."""
139-
return Object(self._path.fan_in)
139+
return Object(self._path.start_point)
140140

141141
@property
142-
def fan_out(self) -> Object:
142+
def end_point(self) -> Object:
143143
"""Get the output signal/object where this path ends."""
144-
return Object(self._path.fan_out)
144+
return Object(self._path.end_point)
145145

146146
@property
147147
def history(self) -> List[DebugPoint]:
@@ -172,11 +172,12 @@ def to_flamegraph(self) -> str:
172172
prefix = f"top:{self.root}"
173173

174174
# Build hierarchy strings for start and end points
175-
fan_in_hierarchy = self._build_hierarchy_string(self.fan_in, prefix)
176-
fan_out_hierarchy = self._build_hierarchy_string(self.fan_out, prefix)
175+
start_point_hierarchy = self._build_hierarchy_string(
176+
self.start_point, prefix)
177+
end_point_hierarchy = self._build_hierarchy_string(self.end_point, prefix)
177178

178179
# Track current position and delay for incremental output
179-
current_hierarchy = fan_in_hierarchy
180+
current_hierarchy = start_point_hierarchy
180181
current_delay = 0
181182

182183
# Process debug history points in reverse order (from input to output)
@@ -192,10 +193,10 @@ def to_flamegraph(self) -> str:
192193
current_hierarchy = history_hierarchy
193194
current_delay = debug_point.delay
194195

195-
# Add final segment to fan-out if there's remaining delay
196+
# Add final segment to end-point if there's remaining delay
196197
if current_delay != self.delay:
197198
final_delay = self.delay - current_delay
198-
trace.append(f"{fan_out_hierarchy} {final_delay}")
199+
trace.append(f"{end_point_hierarchy} {final_delay}")
199200

200201
return "\n".join(trace)
201202

lib/CAPI/Dialect/Synth.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,19 @@ synthLongestPathDataflowPathGetDelay(SynthLongestPathDataflowPath path) {
176176
}
177177

178178
SynthLongestPathObject
179-
synthLongestPathDataflowPathGetFanIn(SynthLongestPathDataflowPath path) {
179+
synthLongestPathDataflowPathGetStartPoint(SynthLongestPathDataflowPath path) {
180180
auto *wrapper = unwrap(path);
181-
auto &fanIn = wrapper->getFanIn();
182-
return wrap(const_cast<Object *>(&fanIn));
181+
auto &startPoint = wrapper->getStartPoint();
182+
return wrap(const_cast<Object *>(&startPoint));
183183
}
184184

185185
SynthLongestPathObject
186-
synthLongestPathDataflowPathGetFanOut(SynthLongestPathDataflowPath path) {
186+
synthLongestPathDataflowPathGetEndPoint(SynthLongestPathDataflowPath path) {
187187
auto *wrapper = unwrap(path);
188-
if (auto *object = std::get_if<Object>(&wrapper->getFanOut())) {
188+
if (auto *object = std::get_if<Object>(&wrapper->getEndPoint())) {
189189
return wrap(object);
190190
}
191-
auto *ptr = std::get_if<DataflowPath::OutputPort>(&wrapper->getFanOut());
191+
auto *ptr = std::get_if<DataflowPath::OutputPort>(&wrapper->getEndPoint());
192192
return wrap(ptr);
193193
}
194194

0 commit comments

Comments
 (0)