Skip to content

Commit 0e781d4

Browse files
committed
[InstanceGraph] Expose choice of top in getAbsolutePaths, NFC.
This exposes a new getAbsolutePaths API where the user may specify an InstanceGraphNode to use as the top of the returned paths. The existing API that does not expose this simply calls the new API using getTopLevelNode(), preserving the previous behavior. An upcoming change will use the new API to get absolute paths relative to a different top.
1 parent 21b9395 commit 0e781d4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

include/circt/Support/InstanceGraph.h

+2
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ struct InstancePathCache {
333333
explicit InstancePathCache(InstanceGraph &instanceGraph)
334334
: instanceGraph(instanceGraph) {}
335335
ArrayRef<InstancePath> getAbsolutePaths(ModuleOpInterface op);
336+
ArrayRef<InstancePath> getAbsolutePaths(ModuleOpInterface op,
337+
InstanceGraphNode *top);
336338

337339
/// Replace an InstanceOp. This is required to keep the cache updated.
338340
void replaceInstance(InstanceOpInterface oldOp, InstanceOpInterface newOp);

lib/Support/InstanceGraph.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,18 @@ InstanceGraph::getInferredTopLevelNodes() {
227227

228228
static InstancePath empty{};
229229

230-
// NOLINTBEGIN(misc-no-recursion)
231230
ArrayRef<InstancePath>
232231
InstancePathCache::getAbsolutePaths(ModuleOpInterface op) {
232+
return getAbsolutePaths(op, instanceGraph.getTopLevelNode());
233+
}
234+
235+
// NOLINTBEGIN(misc-no-recursion)
236+
ArrayRef<InstancePath>
237+
InstancePathCache::getAbsolutePaths(ModuleOpInterface op,
238+
InstanceGraphNode *top) {
233239
InstanceGraphNode *node = instanceGraph[op];
234240

235-
if (node == instanceGraph.getTopLevelNode()) {
241+
if (node == top) {
236242
return empty;
237243
}
238244

0 commit comments

Comments
 (0)